#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 *);
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) {
- zlog_warn("Can't make %s socket stream: %s",
- (af == AF_INET ? "AF_INET" : "AF_INET6"),
- safe_strerror(errno));
+ 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) {
- zlog_warn("interface_list_ioctl: SIOCGLIFNUM failed %s",
- safe_strerror(save_errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL,
+ "interface_list_ioctl: SIOCGLIFNUM failed %s",
+ safe_strerror(errno));
close(sock);
return -1;
}
lifconf.lifc_len = needed;
lifconf.lifc_buf = buf;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ret = ioctl(sock, SIOCGLIFCONF, &lifconf);
}
if (errno == EINVAL)
goto calculate_lifc_len;
- zlog_warn("SIOCGLIFCONF: %s", safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "SIOCGLIFCONF: %s",
+ safe_strerror(errno));
goto end;
}
&& (*(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;
ret = -1;
if (ret < 0) {
- zlog_warn("SIOCGLIFINDEX(%s) failed", ifp->name);
+ flog_err_sys(EC_LIB_SYSTEM_CALL, "SIOCGLIFINDEX(%s) failed",
+ ifp->name);
return ret;
}
* 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));
if (ret < 0) {
if (errno != EADDRNOTAVAIL) {
- zlog_warn("SIOCGLIFNETMASK (%s) fail: %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL,
+ "SIOCGLIFNETMASK (%s) fail: %s",
+ ifp->name, safe_strerror(errno));
return ret;
}
return 0;
if (ifp->flags & IFF_POINTOPOINT)
prefixlen = IPV6_MAX_BITLEN;
else
- zlog_warn("SIOCGLIFSUBNET (%s) fail: %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(EC_LIB_SYSTEM_CALL,
+ "SIOCGLIFSUBNET (%s) fail: %s",
+ ifp->name, safe_strerror(errno));
} else {
prefixlen = lifreq.lifr_addrlen;
}
/* 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;
}
void interface_list(struct zebra_ns *zns)
{
if (zns->ns_id != NS_DEFAULT) {
- zlog_warn("interface_list: ignore NS %u", zns->ns_id);
+ zlog_debug("interface_list: ignore NS %u", zns->ns_id);
return;
}
interface_list_ioctl(AF_INET);