Commit c921c207 authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

net: ipmr: add support for passing full packet on wrong vif

This patch adds support for IGMPMSG_WRVIFWHOLE which is used to pass
full packet and real vif id when the incoming interface is wrong.
While the RP and FHR are setting up state we need to be sending the
registers encapsulated with all the data inside otherwise we lose it.
The RP then decapsulates it and forwards it to the interested parties.
Currently with WRONGVIF we can only be sending empty register packets
and will lose that data.
This behaviour can be enabled by using MRT_PIM with
val == IGMPMSG_WRVIFWHOLE. This doesn't prevent IGMPMSG_WRONGVIF from
happening, it happens in addition to it, also it is controlled by the same
throttling parameters as WRONGVIF (i.e. 1 packet per 3 seconds currently).
Both messages are generated to keep backwards compatibily and avoid
breaking someone who was enabling MRT_PIM with val == 4, since any
positive val is accepted and treated the same.
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 430ac34d
...@@ -254,6 +254,7 @@ struct mr_table { ...@@ -254,6 +254,7 @@ struct mr_table {
atomic_t cache_resolve_queue_len; atomic_t cache_resolve_queue_len;
bool mroute_do_assert; bool mroute_do_assert;
bool mroute_do_pim; bool mroute_do_pim;
bool mroute_do_wrvifwhole;
int mroute_reg_vif_num; int mroute_reg_vif_num;
}; };
......
...@@ -120,6 +120,7 @@ enum { ...@@ -120,6 +120,7 @@ enum {
IPMRA_TABLE_MROUTE_DO_ASSERT, IPMRA_TABLE_MROUTE_DO_ASSERT,
IPMRA_TABLE_MROUTE_DO_PIM, IPMRA_TABLE_MROUTE_DO_PIM,
IPMRA_TABLE_VIFS, IPMRA_TABLE_VIFS,
IPMRA_TABLE_MROUTE_DO_WRVIFWHOLE,
__IPMRA_TABLE_MAX __IPMRA_TABLE_MAX
}; };
#define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1) #define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1)
...@@ -173,5 +174,6 @@ enum { ...@@ -173,5 +174,6 @@ enum {
#define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */ #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
#define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */ #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
#define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */ #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
#define IGMPMSG_WRVIFWHOLE 4 /* For PIM Register and assert processing */
#endif /* _UAPI__LINUX_MROUTE_H */ #endif /* _UAPI__LINUX_MROUTE_H */
...@@ -1052,7 +1052,7 @@ static int ipmr_cache_report(struct mr_table *mrt, ...@@ -1052,7 +1052,7 @@ static int ipmr_cache_report(struct mr_table *mrt,
struct sk_buff *skb; struct sk_buff *skb;
int ret; int ret;
if (assert == IGMPMSG_WHOLEPKT) if (assert == IGMPMSG_WHOLEPKT || assert == IGMPMSG_WRVIFWHOLE)
skb = skb_realloc_headroom(pkt, sizeof(struct iphdr)); skb = skb_realloc_headroom(pkt, sizeof(struct iphdr));
else else
skb = alloc_skb(128, GFP_ATOMIC); skb = alloc_skb(128, GFP_ATOMIC);
...@@ -1060,7 +1060,7 @@ static int ipmr_cache_report(struct mr_table *mrt, ...@@ -1060,7 +1060,7 @@ static int ipmr_cache_report(struct mr_table *mrt,
if (!skb) if (!skb)
return -ENOBUFS; return -ENOBUFS;
if (assert == IGMPMSG_WHOLEPKT) { if (assert == IGMPMSG_WHOLEPKT || assert == IGMPMSG_WRVIFWHOLE) {
/* Ugly, but we have no choice with this interface. /* Ugly, but we have no choice with this interface.
* Duplicate old header, fix ihl, length etc. * Duplicate old header, fix ihl, length etc.
* And all this only to mangle msg->im_msgtype and * And all this only to mangle msg->im_msgtype and
...@@ -1071,8 +1071,11 @@ static int ipmr_cache_report(struct mr_table *mrt, ...@@ -1071,8 +1071,11 @@ static int ipmr_cache_report(struct mr_table *mrt,
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
msg = (struct igmpmsg *)skb_network_header(skb); msg = (struct igmpmsg *)skb_network_header(skb);
memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr)); memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr));
msg->im_msgtype = IGMPMSG_WHOLEPKT; msg->im_msgtype = assert;
msg->im_mbz = 0; msg->im_mbz = 0;
if (assert == IGMPMSG_WRVIFWHOLE)
msg->im_vif = vifi;
else
msg->im_vif = mrt->mroute_reg_vif_num; msg->im_vif = mrt->mroute_reg_vif_num;
ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2; ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2;
ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) + ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) +
...@@ -1372,6 +1375,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1372,6 +1375,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
struct mr_table *mrt; struct mr_table *mrt;
struct vifctl vif; struct vifctl vif;
struct mfcctl mfc; struct mfcctl mfc;
bool do_wrvifwhole;
u32 uval; u32 uval;
/* There's one exception to the lock - MRT_DONE which needs to unlock */ /* There's one exception to the lock - MRT_DONE which needs to unlock */
...@@ -1502,10 +1506,12 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1502,10 +1506,12 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
break; break;
} }
do_wrvifwhole = (val == IGMPMSG_WRVIFWHOLE);
val = !!val; val = !!val;
if (val != mrt->mroute_do_pim) { if (val != mrt->mroute_do_pim) {
mrt->mroute_do_pim = val; mrt->mroute_do_pim = val;
mrt->mroute_do_assert = val; mrt->mroute_do_assert = val;
mrt->mroute_do_wrvifwhole = do_wrvifwhole;
} }
break; break;
case MRT_TABLE: case MRT_TABLE:
...@@ -1983,6 +1989,9 @@ static void ip_mr_forward(struct net *net, struct mr_table *mrt, ...@@ -1983,6 +1989,9 @@ static void ip_mr_forward(struct net *net, struct mr_table *mrt,
MFC_ASSERT_THRESH)) { MFC_ASSERT_THRESH)) {
c->_c.mfc_un.res.last_assert = jiffies; c->_c.mfc_un.res.last_assert = jiffies;
ipmr_cache_report(mrt, skb, true_vifi, IGMPMSG_WRONGVIF); ipmr_cache_report(mrt, skb, true_vifi, IGMPMSG_WRONGVIF);
if (mrt->mroute_do_wrvifwhole)
ipmr_cache_report(mrt, skb, true_vifi,
IGMPMSG_WRVIFWHOLE);
} }
goto dont_forward; goto dont_forward;
} }
...@@ -2659,7 +2668,9 @@ static bool ipmr_fill_table(struct mr_table *mrt, struct sk_buff *skb) ...@@ -2659,7 +2668,9 @@ static bool ipmr_fill_table(struct mr_table *mrt, struct sk_buff *skb)
mrt->mroute_reg_vif_num) || mrt->mroute_reg_vif_num) ||
nla_put_u8(skb, IPMRA_TABLE_MROUTE_DO_ASSERT, nla_put_u8(skb, IPMRA_TABLE_MROUTE_DO_ASSERT,
mrt->mroute_do_assert) || mrt->mroute_do_assert) ||
nla_put_u8(skb, IPMRA_TABLE_MROUTE_DO_PIM, mrt->mroute_do_pim)) nla_put_u8(skb, IPMRA_TABLE_MROUTE_DO_PIM, mrt->mroute_do_pim) ||
nla_put_u8(skb, IPMRA_TABLE_MROUTE_DO_WRVIFWHOLE,
mrt->mroute_do_wrvifwhole))
return false; return false;
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment