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

pim: Fix vrf binding of autorp and mroute socket #18226

Merged
merged 1 commit into from
Feb 24, 2025
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
10 changes: 10 additions & 0 deletions pimd/pim_autorp.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,13 @@ static bool pim_autorp_socket_enable(struct pim_autorp *autorp)
return false;
}

if (vrf_bind(autorp->pim->vrf->vrf_id, fd, NULL)) {
zlog_warn("Could not bind autorp socket to vrf fd=%d: vrf_id=%d: errno=%d: %s",
fd, autorp->pim->vrf->vrf_id, errno, safe_strerror(errno));
close(fd);
return false;
}

if (!pim_autorp_setup(fd)) {
zlog_warn("Could not setup autorp socket fd=%d: errno=%d: %s", fd, errno,
safe_strerror(errno));
Expand Down Expand Up @@ -1549,7 +1556,10 @@ void pim_autorp_init(struct pim_instance *pim)

if (PIM_DEBUG_AUTORP)
zlog_debug("%s: AutoRP Initialized", __func__);
}

void pim_autorp_enable(struct pim_instance *pim)
{
/* Start AutoRP discovery by default on startup */
pim_autorp_start_discovery(pim);
}
Expand Down
1 change: 1 addition & 0 deletions pimd/pim_autorp.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void pim_autorp_rm_ifp(struct interface *ifp);
void pim_autorp_start_discovery(struct pim_instance *pim);
void pim_autorp_stop_discovery(struct pim_instance *pim);
void pim_autorp_init(struct pim_instance *pim);
void pim_autorp_enable(struct pim_instance *pim);
void pim_autorp_finish(struct pim_instance *pim);
int pim_autorp_config_write(struct pim_instance *pim, struct vty *vty);
void pim_autorp_show_autorp(struct vty *vty, struct pim_instance *pim, const char *component,
Expand Down
4 changes: 4 additions & 0 deletions pimd/pim_instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ static int pim_vrf_enable(struct vrf *vrf)

pim_mroute_socket_enable(pim);

#if PIM_IPV == 4
pim_autorp_enable(pim);
#endif

FOR_ALL_INTERFACES (vrf, ifp) {
if (!ifp->info)
continue;
Expand Down
10 changes: 2 additions & 8 deletions pimd/pim_mroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,17 +876,11 @@ int pim_mroute_socket_enable(struct pim_instance *pim)
pim->vrf->name);
#endif

#ifdef SO_BINDTODEVICE
if (pim->vrf->vrf_id != VRF_DEFAULT
&& setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
pim->vrf->name, strlen(pim->vrf->name))) {
zlog_warn("Could not setsockopt SO_BINDTODEVICE: %s",
safe_strerror(errno));
if (vrf_bind(pim->vrf->vrf_id, fd, NULL)) {
zlog_warn("Could not bind to vrf: %s", safe_strerror(errno));
close(fd);
return -3;
}
#endif

}

pim->mroute_socket = fd;
Expand Down
Loading