aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2007-10-05 17:57:44 +0000
committerBill Nottingham <notting@redhat.com>2007-10-05 17:57:44 +0000
commit3e634c64683b759a68388b62337fb3c5547faa52 (patch)
treef521e347520845282abf3c531e0ffde390a17c63
parent35b965fc7c9afd05515869345eb44f2b851fdd00 (diff)
downloadinitscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar
initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar.gz
initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar.bz2
initscripts-3e634c64683b759a68388b62337fb3c5547faa52.tar.xz
initscripts-3e634c64683b759a68388b62337fb3c5547faa52.zip
just suggest an interface name, don't do actual renaming
-rw-r--r--src/rename_device.c89
-rw-r--r--udev/rules.d/60-net.rules2
2 files changed, 4 insertions, 87 deletions
diff --git a/src/rename_device.c b/src/rename_device.c
index 8fb06997..7b3b3699 100644
--- a/src/rename_device.c
+++ b/src/rename_device.c
@@ -269,84 +269,6 @@ char *get_device_by_hwaddr(char *hwaddr) {
return NULL;
}
-int do_rename(char *src, char *target) {
- int sock;
- struct ifreq ifr;
- int ret;
-
- sock = socket(PF_INET, SOCK_DGRAM, 0);
- if (sock == -1)
- return 1;
-
- memset(&ifr,'\0', sizeof(struct ifreq));
- g_strlcpy(ifr.ifr_name, src, IFNAMSIZ);
- g_strlcpy(ifr.ifr_newname, target, IFNAMSIZ);
- ret = ioctl(sock, SIOCSIFNAME, &ifr);
- close(sock);
- return ret;
-}
-
-
-void rename_device(char *src, char *target, struct netdev *current) {
- int rc;
-
- if (!current) {
- current = calloc(1, sizeof(struct netdev));
- current->dev = src;
- }
-
- rc = do_rename(src, target);
- if (rc && errno != ENODEV) {
- char *hw;
- char *nconfig;
- char *curdev;
- char *dev = NULL;
- struct netdev *i, *tmpdev;
- char *fallback = NULL;
-
- hw = get_hwaddr(target);
- if (!hw) {
- devs = get_devs();
- hw = get_hwaddr(target);
- if (!hw)
- return;
- }
-
- nconfig = get_config_by_hwaddr(hw, NULL);
- curdev = get_device_by_hwaddr(hw);
-
- if (nconfig) {
- dev = nconfig;
- for (i = current; i; i = i->next) {
- if (!strcmp(i->dev,dev)) {
- fallback = dev;
- dev = NULL;
- }
- }
- }
- if (!dev)
- asprintf(&dev,"__tmp%d",rand());
- if (!dev)
- return;
- if (fallback) {
- struct tmp *ntmp = calloc(1, sizeof(struct tmp));
-
- ntmp->src = strdup(dev);
- ntmp->target = strdup(fallback);
- if (tmplist)
- ntmp->next = tmplist;
- tmplist = ntmp;
- }
- tmpdev = calloc(1,sizeof(struct netdev));
- tmpdev->dev = curdev;
- if (current)
- tmpdev->next = current;
- current = tmpdev;
- rename_device(curdev, dev, current);
- do_rename(src,target);
- }
-}
-
void take_lock() {
int count = 0;
int lockfd;
@@ -384,7 +306,6 @@ void take_lock() {
int main(int argc, char **argv) {
char *src, *target, *hw;
- struct tmp *tmpdev;
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -408,15 +329,11 @@ int main(int argc, char **argv) {
if (!hw)
goto out_unlock;
target = get_config_by_hwaddr(hw, src);
- if (!target || !strcmp(src,target))
+ if (!target)
goto out_unlock;
+
+ printf("%s", target);
- rename_device(src, target, NULL);
- for (tmpdev = tmplist; tmpdev ; tmpdev = tmpdev->next) {
- rename_device(tmpdev->src, tmpdev->target, NULL);
- }
- printf("INTERFACE=%s\n",target);
- printf("DEVPATH=/class/net/%s\n", target);
out_unlock:
unlink(LOCKFILE);
exit(0);
diff --git a/udev/rules.d/60-net.rules b/udev/rules.d/60-net.rules
index e023edad..718ad5d9 100644
--- a/udev/rules.d/60-net.rules
+++ b/udev/rules.d/60-net.rules
@@ -1,2 +1,2 @@
-ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
+ACTION=="add", SUBSYSTEM=="net", PROGRAM="/lib/udev/rename_device", RESULT=="?*", ENV{INTERFACE_NAME}="$result"
SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"