summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2019-08-13 15:47:23 +0200
committerDavid Lamparter <equinox@diac24.net>2019-09-03 17:18:35 +0200
commit0cf6db21eca516d825431d4a747748a94c890aad (patch)
tree9cd6d2fa6df5f91024a4edc160d4c759bd93d942 /zebra
parenttools: extend checkpatch.pl for frr_{with,each} (diff)
downloadfrr-0cf6db21eca516d825431d4a747748a94c890aad.tar.xz
frr-0cf6db21eca516d825431d4a747748a94c890aad.zip
*: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/if_ioctl_solaris.c6
-rw-r--r--zebra/if_netlink.c2
-rw-r--r--zebra/ioctl.c6
-rw-r--r--zebra/ioctl_solaris.c4
-rw-r--r--zebra/ipforward_proc.c8
-rw-r--r--zebra/ipforward_solaris.c2
-rw-r--r--zebra/ipforward_sysctl.c10
-rw-r--r--zebra/irdp_main.c2
-rw-r--r--zebra/kernel_netlink.c12
-rw-r--r--zebra/kernel_socket.c2
-rw-r--r--zebra/rt_socket.c2
-rw-r--r--zebra/rtadv.c2
-rw-r--r--zebra/zapi_msg.c2
-rw-r--r--zebra/zebra_mpls_openbsd.c4
-rw-r--r--zebra/zebra_netns_notify.c8
-rw-r--r--zebra/zebra_ns.c2
-rw-r--r--zebra/zserv.c2
17 files changed, 38 insertions, 38 deletions
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index 8b539a904..2a2504ebf 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -60,7 +60,7 @@ static int interface_list_ioctl(int af)
size_t needed, lastneeded = 0;
char *buf = NULL;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = socket(af, SOCK_DGRAM, 0);
}
@@ -72,7 +72,7 @@ static int interface_list_ioctl(int af)
}
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 */
@@ -107,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);
}
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index e157c2d70..c71b95f75 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -385,7 +385,7 @@ static int get_iflink_speed(struct interface *interface)
ifdata.ifr_data = (caddr_t)&ecmd;
/* use ioctl to get IP address of an interface */
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sd = vrf_socket(PF_INET, SOCK_DGRAM, IPPROTO_IP,
interface->vrf_id,
NULL);
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index 8202e076a..b461a0888 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -57,7 +57,7 @@ int if_ioctl(unsigned long request, caddr_t buffer)
int ret;
int err = 0;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
zlog_err("Cannot create UDP socket: %s",
@@ -83,7 +83,7 @@ int vrf_if_ioctl(unsigned long request, caddr_t buffer, vrf_id_t vrf_id)
int ret;
int err = 0;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = vrf_socket(AF_INET, SOCK_DGRAM, 0, vrf_id, NULL);
if (sock < 0) {
zlog_err("Cannot create UDP socket: %s",
@@ -110,7 +110,7 @@ static int if_ioctl_ipv6(unsigned long request, caddr_t buffer)
int ret;
int err = 0;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = socket(AF_INET6, SOCK_DGRAM, 0);
if (sock < 0) {
zlog_err("Cannot create IPv6 datagram socket: %s",
diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c
index 1f96fa23e..2c71d949f 100644
--- a/zebra/ioctl_solaris.c
+++ b/zebra/ioctl_solaris.c
@@ -66,7 +66,7 @@ int if_ioctl(unsigned long request, caddr_t buffer)
int ret;
int err;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
@@ -96,7 +96,7 @@ int if_ioctl_ipv6(unsigned long request, caddr_t buffer)
int ret;
int err;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = socket(AF_INET6, SOCK_DGRAM, 0);
if (sock < 0) {
diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c
index 8f44c377b..709d2176a 100644
--- a/zebra/ipforward_proc.c
+++ b/zebra/ipforward_proc.c
@@ -76,7 +76,7 @@ int ipforward_on(void)
{
FILE *fp;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
fp = fopen(proc_ipv4_forwarding, "w");
@@ -97,7 +97,7 @@ int ipforward_off(void)
{
FILE *fp;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
fp = fopen(proc_ipv4_forwarding, "w");
@@ -143,7 +143,7 @@ int ipforward_ipv6_on(void)
{
FILE *fp;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
fp = fopen(proc_ipv6_forwarding, "w");
@@ -165,7 +165,7 @@ int ipforward_ipv6_off(void)
{
FILE *fp;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
fp = fopen(proc_ipv6_forwarding, "w");
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c
index 1bb743059..1a4532824 100644
--- a/zebra/ipforward_solaris.c
+++ b/zebra/ipforward_solaris.c
@@ -83,7 +83,7 @@ static int solaris_nd(const int cmd, const char *parameter, const int value)
strioctl.ic_len = ND_BUFFER_SIZE;
strioctl.ic_dp = nd_buf;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if ((fd = open(device, O_RDWR)) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"failed to open device %s - %s", device,
diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c
index cc9421c27..ac8f53707 100644
--- a/zebra/ipforward_sysctl.c
+++ b/zebra/ipforward_sysctl.c
@@ -56,7 +56,7 @@ int ipforward_on(void)
int ipforwarding = 1;
len = sizeof ipforwarding;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"Can't set ipforwarding on");
@@ -72,7 +72,7 @@ int ipforward_off(void)
int ipforwarding = 0;
len = sizeof ipforwarding;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if (sysctl(mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"Can't set ipforwarding on");
@@ -97,7 +97,7 @@ int ipforward_ipv6(void)
int ip6forwarding = 0;
len = sizeof ip6forwarding;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"can't get ip6forwarding value");
@@ -113,7 +113,7 @@ int ipforward_ipv6_on(void)
int ip6forwarding = 1;
len = sizeof ip6forwarding;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)
< 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
@@ -130,7 +130,7 @@ int ipforward_ipv6_off(void)
int ip6forwarding = 0;
len = sizeof ip6forwarding;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if (sysctl(mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len)
< 0) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 38d241eaa..0de618625 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -82,7 +82,7 @@ int irdp_sock_init(void)
int save_errno;
int sock;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
save_errno = errno;
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 2c306434a..f52b4746a 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -183,7 +183,7 @@ static int netlink_recvbuf(struct nlsock *nl, uint32_t newsize)
}
/* Try force option (linux >= 2.6.14) and fall back to normal set */
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ret = setsockopt(nl->sock, SOL_SOCKET, SO_RCVBUFFORCE,
&nl_rcvbufsize,
sizeof(nl_rcvbufsize));
@@ -220,7 +220,7 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
int sock;
int namelen;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = ns_socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE, ns_id);
if (sock < 0) {
zlog_err("Can't open %s socket: %s", nl->name,
@@ -352,7 +352,7 @@ static void netlink_write_incoming(const char *buf, const unsigned int size,
FILE *f;
snprintf(fname, MAXPATHLEN, "%s/%s_%u", frr_vtydir, "netlink", counter);
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
f = fopen(fname, "w");
}
if (f) {
@@ -373,7 +373,7 @@ static long netlink_read_file(char *buf, const char *fname)
FILE *f;
long file_bytes = -1;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
f = fopen(fname, "r");
}
if (f) {
@@ -989,7 +989,7 @@ int netlink_talk_info(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
n->nlmsg_flags);
/* Send message to netlink interface. */
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
status = sendmsg(nl->sock, &msg, 0);
save_errno = errno;
}
@@ -1056,7 +1056,7 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n)
snl.nl_family = AF_NETLINK;
/* Raise capabilities and send message, then lower capabilities. */
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ret = sendto(nl->sock, (void *)n, n->nlmsg_len, 0,
(struct sockaddr *)&snl, sizeof snl);
}
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 156ce5072..60fbbcc05 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -1426,7 +1426,7 @@ static int kernel_read(struct thread *thread)
/* Make routing socket. */
static void routing_socket(struct zebra_ns *zns)
{
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
routing_sock = ns_socket(AF_ROUTE, SOCK_RAW, 0, zns->ns_id);
dplane_routing_sock =
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index 7e9a42a61..ea3b2b6ad 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -314,7 +314,7 @@ enum zebra_dplane_result kernel_route_update(struct zebra_dplane_ctx *ctx)
type = dplane_ctx_get_type(ctx);
old_type = dplane_ctx_get_old_type(ctx);
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
if (dplane_ctx_get_op(ctx) == DPLANE_OP_ROUTE_DELETE) {
if (!RSYSTEM_ROUTE(type))
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 5841c44b0..b084fb99c 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -760,7 +760,7 @@ static int rtadv_make_socket(ns_id_t ns_id)
int ret = 0;
struct icmp6_filter filter;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
sock = ns_socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6, ns_id);
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index b6a8ee950..fa6a2f62e 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -2507,7 +2507,7 @@ static void zserv_write_incoming(struct stream *orig, uint16_t command)
snprintf(fname, MAXPATHLEN, "%s/%u", frr_vtydir, command);
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
fd = open(fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
}
stream_flush(copy, fd);
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c
index 9f3ea70c7..fcd476dc2 100644
--- a/zebra/zebra_mpls_openbsd.c
+++ b/zebra/zebra_mpls_openbsd.c
@@ -119,7 +119,7 @@ static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label,
hdr.rtm_mpls = MPLS_OP_SWAP;
}
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ret = writev(kr_state.fd, iov, iovcnt);
}
@@ -226,7 +226,7 @@ static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label,
hdr.rtm_mpls = MPLS_OP_SWAP;
}
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ret = writev(kr_state.fd, iov, iovcnt);
}
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c
index 476638591..d42cf3d60 100644
--- a/zebra/zebra_netns_notify.c
+++ b/zebra/zebra_netns_notify.c
@@ -77,7 +77,7 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)
if (netnspath == NULL)
return;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ns_id = zebra_ns_id_get(netnspath);
}
if (ns_id == NS_UNKNOWN)
@@ -97,7 +97,7 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)
ns_map_nsid_with_external(ns_id, false);
return;
}
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ret = vrf_netns_handler_create(NULL, vrf, netnspath,
ns_id_external, ns_id);
}
@@ -202,14 +202,14 @@ static int zebra_ns_ready_read(struct thread *t)
netnspath = zns_info->netnspath;
if (--zns_info->retries == 0)
stop_retry = 1;
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
err = ns_switch_to_netns(netnspath);
}
if (err < 0)
return zebra_ns_continue_read(zns_info, stop_retry);
/* go back to default ns */
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
err = ns_switchback_to_initial();
}
if (err < 0)
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c
index 94918365a..37f53bf91 100644
--- a/zebra/zebra_ns.c
+++ b/zebra/zebra_ns.c
@@ -180,7 +180,7 @@ int zebra_ns_init(const char *optional_default_name)
dzns = zebra_ns_alloc();
- frr_elevate_privs(&zserv_privs) {
+ frr_with_privs(&zserv_privs) {
ns_id = zebra_ns_id_get_default();
}
ns_id_external = ns_map_nsid_with_external(ns_id, true);
diff --git a/zebra/zserv.c b/zebra/zserv.c
index bd75b66a2..c008441d6 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -782,7 +782,7 @@ void zserv_start(char *path)
setsockopt_so_recvbuf(zsock, 1048576);
setsockopt_so_sendbuf(zsock, 1048576);
- frr_elevate_privs((sa.ss_family != AF_UNIX) ? &zserv_privs : NULL) {
+ frr_with_privs((sa.ss_family != AF_UNIX) ? &zserv_privs : NULL) {
ret = bind(zsock, (struct sockaddr *)&sa, sa_len);
}
if (ret < 0) {