]> 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 c463630b12964c4000e8e9479b6002eda67a0709..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"
@@ -71,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) {
                        /*
@@ -642,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;
        }