1
/sbin/ip is actually compiled from the program below.
5
* This exists only to be a accept libvirt's call to 'ip' inside the guest
6
* (LP: 828211). It calls: ip link set veth1 name eth0
9
* gcc -o ip-rename-hack ip-rename-hack.c -static
10
* strip -s ip-rename-hack
11
* cp ip-rename-hack rootd/sbin/ip
16
#include <linux/sockios.h>
23
"Bad Usage: This program only serves to take input of the form\n\
24
ip link set $ORIG name $NEW\n\
26
ip link set veth1 name eth0\n\
27
Any thing else is bogus.\n");
31
int get_socket(void) {
33
fd = socket(PF_INET, SOCK_DGRAM, 0);
36
fd = socket(PF_PACKET, SOCK_DGRAM, 0);
42
int main(int argc, char* argv[]) {
50
if(strcmp(argv[2], "set") || strcmp(argv[4],"name")) {
55
if ((fd = get_socket()) == 0) {
56
fprintf(stderr,"failed to get fd\n");
59
strncpy(ifr.ifr_name, dev, namelen);
60
strncpy(ifr.ifr_newname, newdev, namelen);
61
printf("rename %s to %s\n", dev, newdev);
62
ret = ioctl(fd, SIOCSIFNAME, &ifr);
65
fprintf(stderr, "failed\n");
69
printf("renamed %s to %s\n", dev, newdev);