summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls_openbsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_mpls_openbsd.c')
-rw-r--r--zebra/zebra_mpls_openbsd.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c
index 412fe7d3dd..542de27e83 100644
--- a/zebra/zebra_mpls_openbsd.c
+++ b/zebra/zebra_mpls_openbsd.c
@@ -31,6 +31,7 @@
#include "prefix.h"
#include "interface.h"
#include "log.h"
+#include "lib_errors.h"
extern struct zebra_privs_t zserv_privs;
@@ -116,14 +117,13 @@ static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label,
hdr.rtm_mpls = MPLS_OP_SWAP;
}
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog_err("Can't raise privileges");
- ret = writev(kr_state.fd, iov, iovcnt);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog_err("Can't lower privileges");
+ frr_elevate_privs(&zserv_privs) {
+ ret = writev(kr_state.fd, iov, iovcnt);
+ }
if (ret == -1)
- zlog_err("%s: %s", __func__, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: %s", __func__,
+ safe_strerror(errno));
return ret;
}
@@ -224,14 +224,13 @@ static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label,
hdr.rtm_mpls = MPLS_OP_SWAP;
}
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog_err("Can't raise privileges");
- ret = writev(kr_state.fd, iov, iovcnt);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog_err("Can't lower privileges");
+ frr_elevate_privs(&zserv_privs) {
+ ret = writev(kr_state.fd, iov, iovcnt);
+ }
if (ret == -1)
- zlog_err("%s: %s", __func__, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: %s", __func__,
+ safe_strerror(errno));
return ret;
}
@@ -360,8 +359,8 @@ static int kmpw_install(struct zebra_pw *pw)
imr.imr_type = IMR_TYPE_ETHERNET_TAGGED;
break;
default:
- zlog_err("%s: unhandled pseudowire type (%#X)", __func__,
- pw->type);
+ zlog_warn("%s: unhandled pseudowire type (%#X)", __func__,
+ pw->type);
return -1;
}
@@ -382,8 +381,8 @@ static int kmpw_install(struct zebra_pw *pw)
sa_in6->sin6_addr = pw->nexthop.ipv6;
break;
default:
- zlog_err("%s: unhandled pseudowire address-family (%u)",
- __func__, pw->af);
+ zlog_warn("%s: unhandled pseudowire address-family (%u)",
+ __func__, pw->af);
return -1;
}
memcpy(&imr.imr_nexthop, (struct sockaddr *)&ss,
@@ -398,7 +397,8 @@ static int kmpw_install(struct zebra_pw *pw)
strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)&imr;
if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) {
- zlog_err("ioctl SIOCSETMPWCFG: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s",
+ safe_strerror(errno));
return -1;
}
@@ -415,7 +415,8 @@ static int kmpw_uninstall(struct zebra_pw *pw)
strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)&imr;
if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) {
- zlog_err("ioctl SIOCSETMPWCFG: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s",
+ safe_strerror(errno));
return -1;
}