]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripngd/ripng_interface.c
*: use frr_elevate_privs() (1/2: coccinelle)
[mirror_frr.git] / ripngd / ripng_interface.c
index dbee3ce69ff8a0b10e3d65ed6cc6688b55c70365..ef324b001a734629deaa026eb2f7b957bf8782c3 100644 (file)
@@ -35,6 +35,7 @@
 #include "thread.h"
 #include "privs.h"
 #include "vrf.h"
+#include "lib_errors.h"
 
 #include "ripngd/ripngd.h"
 #include "ripngd/ripng_debug.h"
@@ -47,8 +48,6 @@
 #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP 
 #endif
 
-extern struct zebra_privs_t ripngd_privs;
-
 /* Static utility function. */
 static void ripng_enable_apply(struct interface *);
 static void ripng_passive_interface_apply(struct interface *);
@@ -73,15 +72,14 @@ static int ripng_multicast_join(struct interface *ifp)
                 * While this is bogus, privs are available and easy to use
                 * for this call as a workaround.
                 */
-               if (ripngd_privs.change(ZPRIVS_RAISE))
-                       zlog_err("ripng_multicast_join: could not raise privs");
+               frr_elevate_privs(&ripngd_privs) {
 
-               ret = setsockopt(ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
-                                (char *)&mreq, sizeof(mreq));
-               save_errno = errno;
+                       ret = setsockopt(ripng->sock, IPPROTO_IPV6,
+                                        IPV6_JOIN_GROUP,
+                                        (char *)&mreq, sizeof(mreq));
+                       save_errno = errno;
 
-               if (ripngd_privs.change(ZPRIVS_LOWER))
-                       zlog_err("ripng_multicast_join: could not lower privs");
+               }
 
                if (ret < 0 && save_errno == EADDRINUSE) {
                        /*
@@ -299,7 +297,7 @@ int ripng_interface_delete(int command, struct zclient *zclient,
 
        /* To support pseudo interface do not free interface structure.  */
        /* if_delete(ifp); */
-       ifp->ifindex = IFINDEX_INTERNAL;
+       if_set_index(ifp, IFINDEX_INTERNAL);
 
        return 0;
 }
@@ -310,7 +308,7 @@ void ripng_interface_clean(void)
        struct interface *ifp;
        struct ripng_interface *ri;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                ri->enable_network = 0;
@@ -330,7 +328,7 @@ void ripng_interface_reset(void)
        struct interface *ifp;
        struct ripng_interface *ri;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                ri->enable_network = 0;
@@ -494,7 +492,7 @@ static int ripng_enable_network_lookup_if(struct interface *ifp)
 
        for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) {
                struct prefix *p;
-               struct route_node *node;
+               struct route_node *n;
 
                p = connected->address;
 
@@ -503,10 +501,10 @@ static int ripng_enable_network_lookup_if(struct interface *ifp)
                        address.prefix = p->u.prefix6;
                        address.prefixlen = IPV6_MAX_BITLEN;
 
-                       node = route_node_match(ripng_enable_network,
-                                               (struct prefix *)&address);
-                       if (node) {
-                               route_unlock_node(node);
+                       n = route_node_match(ripng_enable_network,
+                                            (struct prefix *)&address);
+                       if (n) {
+                               route_unlock_node(n);
                                return 1;
                        }
                }
@@ -644,8 +642,9 @@ static int ripng_interface_wakeup(struct thread *t)
 
        /* Join to multicast group. */
        if (ripng_multicast_join(ifp) < 0) {
-               zlog_err("multicast join failed, interface %s not running",
-                        ifp->name);
+               flog_err_sys(LIB_ERR_SOCKET,
+                            "multicast join failed, interface %s not running",
+                            ifp->name);
                return 0;
        }
 
@@ -763,7 +762,7 @@ static void ripng_enable_apply_all(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ripng_enable_apply(ifp);
 }
 
@@ -824,7 +823,7 @@ static void ripng_passive_interface_apply_all(void)
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+       FOR_ALL_INTERFACES (vrf, ifp)
                ripng_passive_interface_apply(ifp);
 }
 
@@ -1074,7 +1073,7 @@ static int interface_config_write(struct vty *vty)
        struct ripng_interface *ri;
        int write = 0;
 
-       RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+       FOR_ALL_INTERFACES (vrf, ifp) {
                ri = ifp->info;
 
                /* Do not display the interface if there is no