Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0] ldpd: *BSD fixes #4254

Merged
merged 3 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions ldpd/ldpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions ldpd/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down
2 changes: 2 additions & 0 deletions zebra/kernel_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down