+static int rename_net_if(struct udevice *dev, int fake)
+{
+ int sk;
+ struct ifreq ifr;
+ int retval;
+
+ dbg("changing net interface name from '%s' to '%s'", dev->kernel_name, dev->name);
+ if (fake)
+ return 0;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ dbg("error opening socket");
+ return -1;
+ }
+
+ memset(&ifr, 0x00, sizeof(struct ifreq));
+ strfieldcpy(ifr.ifr_name, dev->kernel_name);
+ strfieldcpy(ifr.ifr_newname, dev->name);
+
+ retval = ioctl(sk, SIOCSIFNAME, &ifr);
+ if (retval != 0)
+ dbg("error changing net interface name");
+ close(sk);
+
+ return retval;
+}
+