]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/if_ioctl_solaris.c
Merge pull request #5706 from mjstapp/fix_nh_debug_show
[mirror_frr.git] / zebra / if_ioctl_solaris.c
index 1449925aaed5f967dd045486a0f37c7e03d8d5f8..2a2504ebf8adec7b49a23a15bd6623ee7e08e8d9 100644 (file)
@@ -39,6 +39,8 @@
 #include "zebra/interface.h"
 #include "zebra/ioctl_solaris.h"
 #include "zebra/rib.h"
+#include "zebra/rt.h"
+#include "zebra/zebra_errors.h"
 
 static int if_get_addr(struct interface *, struct sockaddr *, const char *);
 static void interface_info_ioctl(struct interface *);
@@ -55,35 +57,32 @@ static int interface_list_ioctl(int af)
        struct lifconf lifconf;
        struct interface *ifp;
        int n;
-       int save_errno;
        size_t needed, lastneeded = 0;
        char *buf = NULL;
 
-       frr_elevate_privs(&zserv_privs) {
+       frr_with_privs(&zserv_privs) {
                sock = socket(af, SOCK_DGRAM, 0);
        }
 
        if (sock < 0) {
-               flog_err_sys(LIB_ERR_SOCKET, "Can't make %s socket stream: %s",
+               flog_err_sys(EC_LIB_SOCKET, "Can't make %s socket stream: %s",
                             (af == AF_INET ? "AF_INET" : "AF_INET6"),
                             safe_strerror(errno));
                return -1;
        }
 
 calculate_lifc_len:
-       frr_elevate_privs(&zserv_privs) {
+       frr_with_privs(&zserv_privs) {
                lifn.lifn_family = af;
                lifn.lifn_flags = LIFC_NOXMIT;
                /* we want NOXMIT interfaces too */
                ret = ioctl(sock, SIOCGLIFNUM, &lifn);
-               save_errno = errno;
-
        }
 
        if (ret < 0) {
-               flog_err_sys(LIB_ERR_SYSTEM_CALL,
+               flog_err_sys(EC_LIB_SYSTEM_CALL,
                             "interface_list_ioctl: SIOCGLIFNUM failed %s",
-                            safe_strerror(save_errno));
+                            safe_strerror(errno));
                close(sock);
                return -1;
        }
@@ -108,7 +107,7 @@ calculate_lifc_len:
        lifconf.lifc_len = needed;
        lifconf.lifc_buf = buf;
 
-       frr_elevate_privs(&zserv_privs) {
+       frr_with_privs(&zserv_privs) {
                ret = ioctl(sock, SIOCGLIFCONF, &lifconf);
        }
 
@@ -116,7 +115,7 @@ calculate_lifc_len:
                if (errno == EINVAL)
                        goto calculate_lifc_len;
 
-               flog_err_sys(LIB_ERR_SYSTEM_CALL, "SIOCGLIFCONF: %s",
+               flog_err_sys(EC_LIB_SYSTEM_CALL, "SIOCGLIFCONF: %s",
                             safe_strerror(errno));
                goto end;
        }
@@ -157,7 +156,7 @@ calculate_lifc_len:
                       && (*(lifreq->lifr_name + normallen) != ':'))
                        normallen++;
 
-               ifp = if_get_by_name(lifreq->lifr_name, VRF_DEFAULT, 0);
+               ifp = if_get_by_name(lifreq->lifr_name, VRF_DEFAULT);
 
                if (lifreq->lifr_addr.ss_family == AF_INET)
                        ifp->flags |= IFF_IPV4;
@@ -208,7 +207,7 @@ static int if_get_index(struct interface *ifp)
                ret = -1;
 
        if (ret < 0) {
-               flog_err_sys(LIB_ERR_SYSTEM_CALL, "SIOCGLIFINDEX(%s) failed",
+               flog_err_sys(EC_LIB_SYSTEM_CALL, "SIOCGLIFINDEX(%s) failed",
                             ifp->name);
                return ret;
        }
@@ -248,7 +247,8 @@ static int if_get_addr(struct interface *ifp, struct sockaddr *addr,
         * We need to use the logical interface name / label, if we've been
         * given one, in order to get the right address
         */
-       strncpy(lifreq.lifr_name, (label ? label : ifp->name), IFNAMSIZ);
+       strlcpy(lifreq.lifr_name, (label ? label : ifp->name),
+               sizeof(lifreq.lifr_name));
 
        /* Interface's address. */
        memcpy(&lifreq.lifr_addr, addr, ADDRLEN(addr));
@@ -271,7 +271,7 @@ static int if_get_addr(struct interface *ifp, struct sockaddr *addr,
 
                if (ret < 0) {
                        if (errno != EADDRNOTAVAIL) {
-                               flog_err_sys(LIB_ERR_SYSTEM_CALL,
+                               flog_err_sys(EC_LIB_SYSTEM_CALL,
                                             "SIOCGLIFNETMASK (%s) fail: %s",
                                             ifp->name, safe_strerror(errno));
                                return ret;
@@ -292,7 +292,7 @@ static int if_get_addr(struct interface *ifp, struct sockaddr *addr,
                        if (ifp->flags & IFF_POINTOPOINT)
                                prefixlen = IPV6_MAX_BITLEN;
                        else
-                               flog_err_sys(LIB_ERR_SYSTEM_CALL,
+                               flog_err_sys(EC_LIB_SYSTEM_CALL,
                                             "SIOCGLIFSUBNET (%s) fail: %s",
                                             ifp->name, safe_strerror(errno));
                } else {
@@ -303,10 +303,11 @@ static int if_get_addr(struct interface *ifp, struct sockaddr *addr,
        /* Set address to the interface. */
        if (af == AF_INET)
                connected_add_ipv4(ifp, flags, &SIN(addr)->sin_addr, prefixlen,
-                                  (struct in_addr *)dest_pnt, label);
+                                  (struct in_addr *)dest_pnt, label,
+                                  METRIC_MAX);
        else if (af == AF_INET6)
                connected_add_ipv6(ifp, flags, &SIN6(addr)->sin6_addr, NULL,
-                                  prefixlen, label);
+                                  prefixlen, label, METRIC_MAX);
 
        return 0;
 }