netlink: Fix IFF_UP flag handling in RTM_NEWLINK's modify_link handler
IFF_UP could previously only be unset via RTM_NEWLINK. Requests to set IFF_UP, though they succeed, did not actually set the flag. RTM_NEWLINK messages with ifi_change=0 are treated as ifi_change=0xFFFFFFFF, modifying all the link flags (currently IFF_UP and IFF_PROMISC) to match the behavior seen on Linux. Reviewed by: obiwac, kp, mckusick (mentor) Approved by: obiwac, mckusick (mentor) Sponsored by: Google LLC (GSoC) Differential Revision: https://reviews.freebsd.org/D51871
This commit is contained in:
committed by
Aymeric Wibo
parent
9a3edc8d5d
commit
39dbadb7a4
@@ -82,8 +82,11 @@ _nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
|
||||
}
|
||||
}
|
||||
|
||||
if ((lattrs->ifi_change & IFF_UP) && (lattrs->ifi_flags & IFF_UP) == 0) {
|
||||
/* Request to down the interface */
|
||||
if ((lattrs->ifi_change & IFF_UP) != 0 || lattrs->ifi_change == 0) {
|
||||
/* Request to up or down the interface */
|
||||
if (lattrs->ifi_flags & IFF_UP)
|
||||
if_up(ifp);
|
||||
else
|
||||
if_down(ifp);
|
||||
}
|
||||
|
||||
@@ -97,7 +100,8 @@ _nl_modify_ifp_generic(struct ifnet *ifp, struct nl_parsed_link *lattrs,
|
||||
}
|
||||
}
|
||||
|
||||
if (lattrs->ifi_change & IFF_PROMISC) {
|
||||
if ((lattrs->ifi_change & IFF_PROMISC) != 0 ||
|
||||
lattrs->ifi_change == 0) {
|
||||
error = ifpromisc(ifp, lattrs->ifi_flags & IFF_PROMISC);
|
||||
if (error != 0) {
|
||||
nlmsg_report_err_msg(npt, "unable to set promisc");
|
||||
|
||||
Reference in New Issue
Block a user