Correctly handle ifr.ifr_flags/ifr.ifr_flagshigh like ifconfig(8) does.
MFC after: 1 day
This commit is contained in:
parent
3aea1e1405
commit
88202a1f33
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102574
@ -454,14 +454,15 @@ setifflags(vname, value)
|
||||
exit(1);
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
flags = ifr.ifr_flags;
|
||||
flags = (ifr.ifr_flags & 0xffff) | (ifr.ifr_flagshigh << 16);
|
||||
|
||||
if (value < 0) {
|
||||
value = -value;
|
||||
flags &= ~value;
|
||||
} else
|
||||
flags |= value;
|
||||
ifr.ifr_flags = flags;
|
||||
ifr.ifr_flags = flags & 0xffff;
|
||||
ifr.ifr_flagshigh = flags >> 16;
|
||||
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
|
||||
Perror(vname);
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ static int
|
||||
iface_ChangeFlags(const char *ifname, int flags, int how)
|
||||
{
|
||||
struct ifreq ifrq;
|
||||
int s;
|
||||
int s, new_flags;
|
||||
|
||||
s = ID0socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
@ -565,11 +565,14 @@ iface_ChangeFlags(const char *ifname, int flags, int how)
|
||||
close(s);
|
||||
return 0;
|
||||
}
|
||||
new_flags = (ifrq.ifr_flags & 0xffff) | (ifrq.ifr_flagshigh << 16);
|
||||
|
||||
if (how == IFACE_ADDFLAGS)
|
||||
ifrq.ifr_flags |= flags;
|
||||
new_flags |= flags;
|
||||
else
|
||||
ifrq.ifr_flags &= ~flags;
|
||||
new_flags &= ~flags;
|
||||
ifrq.ifr_flags = new_flags & 0xffff;
|
||||
ifrq.ifr_flagshigh = new_flags >> 16;
|
||||
|
||||
if (ID0ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) {
|
||||
log_Printf(LogERROR, "iface_ChangeFlags: ioctl(SIOCSIFFLAGS): %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user