]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/if_netlink.c
*: use frr_elevate_privs() (1/2: coccinelle)
[mirror_frr.git] / zebra / if_netlink.c
index e09d30a207e2e74670c44813a8c69caf13b19acd..c0da066aa083a3d601145d348660ae9062dd9e1a 100644 (file)
@@ -375,20 +375,19 @@ static int get_iflink_speed(struct interface *interface)
        ifdata.ifr_data = (caddr_t)&ecmd;
 
        /* use ioctl to get IP address of an interface */
-       if (zserv_privs.change(ZPRIVS_RAISE))
-               flog_err(LIB_ERR_PRIVILEGES, "Can't raise privileges");
-       sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP, interface->vrf_id,
-                       NULL);
-       if (sd < 0) {
-               if (IS_ZEBRA_DEBUG_KERNEL)
-                       zlog_debug("Failure to read interface %s speed: %d %s",
-                                  ifname, errno, safe_strerror(errno));
-               return 0;
-       }
+       frr_elevate_privs(&zserv_privs) {
+               sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP,
+                               interface->vrf_id,
+                               NULL);
+               if (sd < 0) {
+                       if (IS_ZEBRA_DEBUG_KERNEL)
+                               zlog_debug("Failure to read interface %s speed: %d %s",
+                                          ifname, errno, safe_strerror(errno));
+                       return 0;
+               }
        /* Get the current link state for the interface */
-       rc = vrf_ioctl(interface->vrf_id, sd, SIOCETHTOOL, (char *)&ifdata);
-       if (zserv_privs.change(ZPRIVS_LOWER))
-               flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
+               rc = vrf_ioctl(interface->vrf_id, sd, SIOCETHTOOL, (char *)&ifdata);
+       }
        if (rc < 0) {
                if (IS_ZEBRA_DEBUG_KERNEL)
                        zlog_debug(