Skip to content

Commit

Permalink
if.c - vlan parent devices automatically disable
Browse files Browse the repository at this point in the history
disable the child interface and change parent and enable interface after the change made...

issue reported by Tom... fix authored by stsp 
tested by Tom and reviewed OK Tom and OK Chris
  • Loading branch information
smytht authored Oct 11, 2024
1 parent 2177586 commit fd352ad
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions if.c
Original file line number Diff line number Diff line change
Expand Up @@ -2345,7 +2345,8 @@ intrtlabel(char *ifname, int ifs, int argc, char **argv)
int
intparent(char *ifname, int ifs, int argc, char **argv)
{
int set;
int set, ret;
unsigned long cmd;
struct if_parent ifp;

if (NO_ARG(argv[0])) {
Expand Down Expand Up @@ -2374,9 +2375,22 @@ intparent(char *ifname, int ifs, int argc, char **argv)
return 0;
}

if (ioctl(ifs, set ? SIOCSIFPARENT : SIOCDIFPARENT, &ifp) == -1)
printf("%% intparent: SIOC%sIFPARENT: %s\n", set ? "S" : "D",
strerror(errno));
cmd = (set ? SIOCSIFPARENT : SIOCDIFPARENT);
ret = ioctl(ifs, cmd, &ifp);
if (ret == -1) {
if (errno == EBUSY) {
int flags = get_ifflags(ifname, ifs);
if (flags & IFF_UP) {
/* Toggle interface down and retry. and bring the interface back up*/
set_ifflags(ifname, ifs, flags & ~IFF_UP);
ret = ioctl(ifs, cmd, &ifp);
set_ifflags(ifname, ifs, flags);
}
}
if (ret == -1)
printf("%% intparent: SIOC%sIFPARENT: %s\n",
set ? "S" : "D", strerror(errno));
}

return 0;
}
Expand Down

0 comments on commit fd352ad

Please sign in to comment.