Skip to content
Permalink
Browse files

Merge pull request #4254 from opensourcerouting/fixes-for-6.0

 [6.0] ldpd: *BSD fixes
  • Loading branch information...
donaldsharp committed May 3, 2019
2 parents 4a36086 + 16927ec commit eaefb842ffb3d40c40f998a78e8fde080f332b0f
Showing with 23 additions and 10 deletions.
  1. +10 −8 ldpd/ldpe.c
  2. +11 −2 ldpd/socket.c
  3. +2 −0 zebra/kernel_socket.c
@@ -139,6 +139,16 @@ ldpe(void)
void
ldpe_init(struct ldpd_init *init)
{
#ifdef __OpenBSD__
/* This socket must be open before dropping privileges. */
global.pfkeysock = pfkey_init();
if (sysdep.no_pfkey == 0) {
pfkey_ev = NULL;
thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
&pfkey_ev);
}
#endif

/* drop privileges */
ldpe_privs.user = init->user;
ldpe_privs.group = init->group;
@@ -159,14 +169,6 @@ ldpe_init(struct ldpd_init *init)
fatal("inet_pton");
if (inet_pton(AF_INET6, AllRouters_v6, &global.mcast_addr_v6) != 1)
fatal("inet_pton");
#ifdef __OpenBSD__
global.pfkeysock = pfkey_init();
if (sysdep.no_pfkey == 0) {
pfkey_ev = NULL;
thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
&pfkey_ev);
}
#endif

/* mark sockets as closed */
global.ipv4.ldp_disc_socket = -1;
@@ -268,9 +268,18 @@ sock_set_bindany(int fd, int enable)
return (-1);
}
return (0);
#elif defined(IP_BINDANY)
frr_elevate_privs(&ldpd_privs) {
if (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &enable, sizeof(int))
< 0) {
log_warn("%s: error setting IP_BINDANY", __func__);
return (-1);
}
}
#else
log_warnx("%s: missing SO_BINDANY and IP_FREEBIND, unable to bind "
"to a nonlocal IP address", __func__);
log_warnx(
"%s: missing SO_BINDANY, IP_FREEBIND and IP_BINDANY, unable to bind to a nonlocal IP address",
__func__);
return (-1);
#endif /* HAVE_SO_BINDANY */
}
@@ -194,7 +194,9 @@ const struct message rtm_type_str[] = {{RTM_ADD, "RTM_ADD"},
{RTM_LOSING, "RTM_LOSING"},
{RTM_REDIRECT, "RTM_REDIRECT"},
{RTM_MISS, "RTM_MISS"},
#ifdef RTM_LOCK
{RTM_LOCK, "RTM_LOCK"},
#endif /* RTM_LOCK */
#ifdef OLDADD
{RTM_OLDADD, "RTM_OLDADD"},
#endif /* RTM_OLDADD */

0 comments on commit eaefb84

Please sign in to comment.
You can’t perform that action at this time.