summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pimd/pim_iface.c7
-rw-r--r--pimd/pim_iface.h1
-rw-r--r--pimd/pim_mroute.c22
-rw-r--r--pimd/pim_register.c2
-rw-r--r--pimd/pim_rp.c35
5 files changed, 23 insertions, 44 deletions
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 1ffea6ab4..fae11b674 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -87,7 +87,6 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim)
pim_ifp->options = 0;
pim_ifp->mroute_vif_index = -1;
- pim_ifp->pim_raw_fd = -1;
pim_ifp->igmp_default_robustness_variable = IGMP_DEFAULT_ROBUSTNESS_VARIABLE;
pim_ifp->igmp_default_query_interval = IGMP_GENERAL_QUERY_INTERVAL;
@@ -163,12 +162,6 @@ void pim_if_delete(struct interface *ifp)
pim_ifp = ifp->info;
zassert(pim_ifp);
- if (pim_ifp->pim_raw_fd == -1)
- {
- close (pim_ifp->pim_raw_fd);
- pim_ifp->pim_raw_fd = -1;
- }
-
if (pim_ifp->igmp_join_list) {
pim_if_igmp_join_del_all(ifp);
}
diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h
index 7f3d6961f..75b85c306 100644
--- a/pimd/pim_iface.h
+++ b/pimd/pim_iface.h
@@ -73,7 +73,6 @@ struct pim_interface {
struct list *igmp_join_list; /* list of struct igmp_join */
int pim_sock_fd; /* PIM socket file descriptor */
- int pim_raw_fd; /* RP forwarding */
struct thread *t_pim_sock_read; /* thread for reading PIM socket */
int64_t pim_sock_creation; /* timestamp of PIM socket creation */
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 7893bc926..8efe7635c 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -570,6 +570,7 @@ int pim_mroute_add(struct channel_oil *c_oil)
{
int err;
int orig = 0;
+ int orig_iif_vif = 0;
qpim_mroute_add_last = pim_time_monotonic_sec();
++qpim_mroute_add_events;
@@ -590,9 +591,30 @@ int pim_mroute_add(struct channel_oil *c_oil)
c_oil->oil.mfcc_ttls[c_oil->oil.mfcc_parent] = 1;
}
+ /*
+ * If we have an unresolved cache entry for the S,G
+ * it is owned by the pimreg for the incoming IIF
+ * So set pimreg as the IIF temporarily to cause
+ * the packets to be forwarded. Then set it
+ * to the correct IIF afterwords.
+ */
+ if (!c_oil->installed && c_oil->oil.mfcc_origin.s_addr != INADDR_ANY &&
+ c_oil->oil.mfcc_parent != 0)
+ {
+ orig_iif_vif = c_oil->oil.mfcc_parent;
+ c_oil->oil.mfcc_parent = 0;
+ }
err = setsockopt(qpim_mroute_socket_fd, IPPROTO_IP, MRT_ADD_MFC,
&c_oil->oil, sizeof(c_oil->oil));
+ if (!err && !c_oil->installed && c_oil->oil.mfcc_origin.s_addr != INADDR_ANY &&
+ orig_iif_vif != 0)
+ {
+ c_oil->oil.mfcc_parent = orig_iif_vif;
+ err = setsockopt (qpim_mroute_socket_fd, IPPROTO_IP, MRT_ADD_MFC,
+ &c_oil->oil, sizeof (c_oil->oil));
+ }
+
if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY)
c_oil->oil.mfcc_ttls[c_oil->oil.mfcc_parent] = orig;
diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index da84e245d..aaf05bbb1 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -348,9 +348,9 @@ pim_register_recv (struct interface *ifp,
if (!(upstream->sptbit == PIM_UPSTREAM_SPTBIT_TRUE) &&
!(*bits & PIM_REGISTER_NR_BIT))
{
- pim_rp_forward_packet (ip_hdr);
//decapsulate and forward the iner packet to
//inherited_olist(S,G,rpt)
+ // This is taken care of by the kernel for us
}
} else {
pim_register_stop_send (ifp, &sg, src_addr);
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 929211cdd..b98ff2859 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -33,38 +33,6 @@
static int i_am_rp = 0;
-/*
- * The Raw socket to pump packets down
- * if we are the RP
- */
-static int fd_rp = -1;
-
-void
-pim_rp_forward_packet (struct ip *ip_hdr)
-{
- struct sockaddr_in sin;
-
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = ip_hdr->ip_dst.s_addr;
-
- zlog_debug ("Sending Packet");
- if (sendto (fd_rp, ip_hdr, ntohs (ip_hdr->ip_len), 0, (struct sockaddr *)&sin, sizeof (struct sockaddr)) < 0)
- {
- zlog_debug ("Failure to send packet: %s", safe_strerror (errno));
- }
-}
-
-static void
-pim_rp_create_socket (void)
-{
- fd_rp = pim_socket_raw (IPPROTO_RAW);
-
- if (pim_socket_ip_hdr (fd_rp) != 0)
- zlog_debug ("Unable to setup socket for ip hdr inclusion");
-
- if (pim_socket_bind (fd_rp, qpim_rp.source_nexthop.interface) != 0)
- zlog_debug ("Unable to Bind to a particular socket");
-}
int
pim_rp_setup (void)
@@ -75,8 +43,6 @@ pim_rp_setup (void)
return 0;
}
- pim_rp_create_socket ();
-
return 1;
}
@@ -102,7 +68,6 @@ pim_rp_check_rp (struct in_addr old, struct in_addr new)
if (new.s_addr == qpim_rp.rpf_addr.s_addr)
{
i_am_rp = 1;
- pim_rp_create_socket();
return;
}