summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-10-30 20:12:07 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-10-31 12:26:35 +0100
commite5a2ebe6913b1aeac97610e2c0101b59591f01dc (patch)
tree96a9801b712174ed571652b65282c5666768ad83 /pimd
parentpimd: *bsd needs priviledge escalation to init PIM (diff)
downloadfrr-e5a2ebe6913b1aeac97610e2c0101b59591f01dc.tar.xz
frr-e5a2ebe6913b1aeac97610e2c0101b59591f01dc.zip
pimd: Send 1 on all systems for MRT_INIT
When sending a sockoption for MRT_INIT, *bsd requires that the data passed in must be 1. While linux does not, the code was sending in a positive value that was causing issues on *bsd of protocol not supported. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_mroute.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 8ad9a28ae..dc4c4402a 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -48,8 +48,8 @@ static void mroute_read_on(struct pim_instance *pim);
static int pim_mroute_set(struct pim_instance *pim, int enable)
{
int err;
- int opt;
- socklen_t opt_len = sizeof(opt);
+ int opt, data;
+ socklen_t data_len = sizeof(data);
long flags;
/*
@@ -58,15 +58,15 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
if (pim->vrf_id != VRF_DEFAULT) {
frr_elevate_privs(&pimd_privs) {
- opt = pim->vrf->data.l.table_id;
+ data = pim->vrf->data.l.table_id;
err = setsockopt(pim->mroute_socket, IPPROTO_IP,
MRT_TABLE,
- &opt, opt_len);
+ &data, data_len);
if (err) {
zlog_warn(
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s",
__FILE__, __PRETTY_FUNCTION__,
- pim->mroute_socket, opt, errno,
+ pim->mroute_socket, data, errno,
safe_strerror(errno));
return -1;
}
@@ -76,14 +76,19 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
frr_elevate_privs(&pimd_privs) {
opt = enable ? MRT_INIT : MRT_DONE;
+ /*
+ * *BSD *cares* about what value we pass down
+ * here
+ */
+ data = 1;
err = setsockopt(pim->mroute_socket, IPPROTO_IP,
- opt, &opt, opt_len);
+ opt, &data, data_len);
if (err) {
zlog_warn(
"%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s",
__FILE__, __PRETTY_FUNCTION__,
pim->mroute_socket,
- enable ? "MRT_INIT" : "MRT_DONE", opt, errno,
+ enable ? "MRT_INIT" : "MRT_DONE", data, errno,
safe_strerror(errno));
return -1;
}
@@ -92,9 +97,9 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
#if defined(HAVE_IP_PKTINFO)
if (enable) {
/* Linux and Solaris IP_PKTINFO */
- opt = 1;
- if (setsockopt(pim->mroute_socket, IPPROTO_IP, IP_PKTINFO, &opt,
- sizeof(opt))) {
+ data = 1;
+ if (setsockopt(pim->mroute_socket, IPPROTO_IP, IP_PKTINFO,
+ &data, data_len)) {
zlog_warn(
"Could not set IP_PKTINFO on socket fd=%d: errno=%d: %s",
pim->mroute_socket, errno,