Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160409368
D57349.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D57349.diff
View Options
diff --git a/sys/netlink/route/iface_drivers.c b/sys/netlink/route/iface_drivers.c
--- a/sys/netlink/route/iface_drivers.c
+++ b/sys/netlink/route/iface_drivers.c
@@ -69,17 +69,16 @@
int error;
if (lattrs->ifla_ifalias != NULL) {
- if (nlp_has_priv(npt->nlp, PRIV_NET_SETIFDESCR)) {
- int len = strlen(lattrs->ifla_ifalias) + 1;
- char *buf = if_allocdescr(len, M_WAITOK);
-
- memcpy(buf, lattrs->ifla_ifalias, len);
- if_setdescr(ifp, buf);
- if_setlastchange(ifp);
- } else {
+ if (!nlp_has_priv(npt->nlp, PRIV_NET_SETIFDESCR)) {
nlmsg_report_err_msg(npt, "Not enough privileges to set descr");
return (EPERM);
}
+ int len = strlen(lattrs->ifla_ifalias) + 1;
+ char *buf = if_allocdescr(len, M_WAITOK);
+
+ memcpy(buf, lattrs->ifla_ifalias, len);
+ if_setdescr(ifp, buf);
+ if_setlastchange(ifp);
}
if ((lattrs->ifi_change & IFF_UP) != 0 || lattrs->ifi_change == 0) {
@@ -91,18 +90,17 @@
}
if (lattrs->ifla_mtu > 0) {
- if (nlp_has_priv(npt->nlp, PRIV_NET_SETIFMTU)) {
- struct ifreq ifr = { .ifr_mtu = lattrs->ifla_mtu };
- error = ifhwioctl(SIOCSIFMTU, ifp, (char *)&ifr,
- curthread);
- if (error != 0) {
- nlmsg_report_err_msg(npt, "Failed to set mtu");
- return (error);
- }
- } else {
+ if (!nlp_has_priv(npt->nlp, PRIV_NET_SETIFMTU)) {
nlmsg_report_err_msg(npt, "Not enough privileges to set mtu");
return (EPERM);
}
+ struct ifreq ifr = { .ifr_mtu = lattrs->ifla_mtu };
+ error = ifhwioctl(SIOCSIFMTU, ifp, (char *)&ifr,
+ curthread);
+ if (error != 0) {
+ nlmsg_report_err_msg(npt, "Failed to set mtu");
+ return (error);
+ }
}
if ((lattrs->ifi_change & IFF_PROMISC) != 0 ||
@@ -117,21 +115,20 @@
if_setppromisc(ifp, (lattrs->ifi_flags & IFF_PROMISC) != 0);
if (lattrs->ifla_address != NULL) {
- if (nlp_has_priv(npt->nlp, PRIV_NET_SETIFMAC)) {
- error = if_setlladdr(ifp,
- NLA_DATA(lattrs->ifla_address),
- NLA_DATA_LEN(lattrs->ifla_address));
- if (error != 0) {
- nlmsg_report_err_msg(npt,
- "setting IFLA_ADDRESS failed with error code: %d",
- error);
- return (error);
- }
- } else {
+ if (!nlp_has_priv(npt->nlp, PRIV_NET_SETIFMAC)) {
nlmsg_report_err_msg(npt,
"Not enough privileges to set IFLA_ADDRESS");
return (EPERM);
}
+ error = if_setlladdr(ifp,
+ NLA_DATA(lattrs->ifla_address),
+ NLA_DATA_LEN(lattrs->ifla_address));
+ if (error != 0) {
+ nlmsg_report_err_msg(npt,
+ "setting IFLA_ADDRESS failed with error code: %d",
+ error);
+ return (error);
+ }
}
return (0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jun 25, 5:27 AM (8 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33640998
Default Alt Text
D57349.diff (2 KB)
Attached To
Mode
D57349: netlink: Use early exit pattern in _nl_modify_ifp_generic
Attached
Detach File
Event Timeline
Log In to Comment