Merge branch 'frr/pull/165' ("Pim vrf")

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-02-07 15:52:52 +01:00
commit f6864de1ab
4 changed files with 14 additions and 19 deletions

View File

@ -41,20 +41,20 @@ static void group_timer_off(struct igmp_group *group);
/* This socket is used for TXing IGMP packets only, IGMP RX happens
* in pim_mroute_msg()
*/
static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim_options)
static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp, uint32_t pim_options)
{
int fd;
int join = 0;
struct in_addr group;
fd = pim_socket_mcast(IPPROTO_IGMP, ifaddr, ifindex, 1);
fd = pim_socket_mcast(IPPROTO_IGMP, ifaddr, ifp, 1);
if (fd < 0)
return -1;
if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options)) {
if (inet_aton(PIM_ALL_ROUTERS, &group)) {
if (!pim_socket_join(fd, group, ifaddr, ifindex))
if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex))
++join;
}
else {
@ -69,7 +69,7 @@ static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim
IGMP routers must receive general queries for querier election.
*/
if (inet_aton(PIM_ALL_SYSTEMS, &group)) {
if (!pim_socket_join(fd, group, ifaddr, ifindex))
if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex))
++join;
}
else {
@ -79,7 +79,7 @@ static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim
}
if (inet_aton(PIM_ALL_IGMP_ROUTERS, &group)) {
if (!pim_socket_join(fd, group, ifaddr, ifindex)) {
if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex)) {
++join;
}
}
@ -901,7 +901,7 @@ struct igmp_sock *pim_igmp_sock_add(struct list *igmp_sock_list,
pim_ifp = ifp->info;
fd = igmp_sock_open(ifaddr, ifp->ifindex, pim_ifp->options);
fd = igmp_sock_open(ifaddr, ifp, pim_ifp->options);
if (fd < 0) {
zlog_warn("Could not open IGMP socket for %s on %s",
inet_ntoa(ifaddr), ifp->name);

View File

@ -389,15 +389,16 @@ static void pim_sock_read_on(struct interface *ifp)
pim_ifp->pim_sock_fd);
}
static int pim_sock_open(struct in_addr ifaddr, ifindex_t ifindex)
static int pim_sock_open(struct interface *ifp)
{
int fd;
struct pim_interface *pim_ifp = ifp->info;
fd = pim_socket_mcast(IPPROTO_PIM, ifaddr, ifindex, 0 /* loop=false */);
fd = pim_socket_mcast(IPPROTO_PIM, pim_ifp->primary_address, ifp, 0 /* loop=false */);
if (fd < 0)
return -1;
if (pim_socket_join(fd, qpim_all_pim_routers_addr, ifaddr, ifindex)) {
if (pim_socket_join(fd, qpim_all_pim_routers_addr, pim_ifp->primary_address, ifp->ifindex)) {
close(fd);
return -2;
}
@ -793,7 +794,6 @@ void pim_hello_restart_triggered(struct interface *ifp)
int pim_sock_add(struct interface *ifp)
{
struct pim_interface *pim_ifp;
struct in_addr ifaddr;
uint32_t old_genid;
pim_ifp = ifp->info;
@ -806,9 +806,7 @@ int pim_sock_add(struct interface *ifp)
return -1;
}
ifaddr = pim_ifp->primary_address;
pim_ifp->pim_sock_fd = pim_sock_open(ifaddr, ifp->ifindex);
pim_ifp->pim_sock_fd = pim_sock_open(ifp);
if (pim_ifp->pim_sock_fd < 0) {
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug("Could not open PIM socket on interface %s",

View File

@ -111,7 +111,7 @@ pim_socket_bind (int fd, struct interface *ifp)
return ret;
}
int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char loop)
int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp, u_char loop)
{
int rcvbuf = 1024 * 1024 * 8;
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
@ -132,9 +132,6 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char lo
if (protocol == IPPROTO_PIM)
{
int ret;
struct interface *ifp = NULL;
ifp = if_lookup_by_index_vrf (ifindex, VRF_DEFAULT);
ret = pim_socket_bind (fd, ifp);
if (ret)
@ -223,7 +220,7 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char lo
memset (&mreq, 0, sizeof (mreq));
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
mreq.imr_ifindex = ifindex;
mreq.imr_ifindex = ifp->ifindex;
#else
/*
* I am not sure what to do here yet for *BSD

View File

@ -39,7 +39,7 @@
int pim_socket_bind (int fd, struct interface *ifp);
int pim_socket_ip_hdr (int fd);
int pim_socket_raw(int protocol);
int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char loop);
int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp, u_char loop);
int pim_socket_join(int fd, struct in_addr group,
struct in_addr ifaddr, ifindex_t ifindex);
int pim_socket_join_source(int fd, ifindex_t ifindex,