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

net: sched: em_ipt: set the family based on the packet if it's unspecified

Set the family based on the packet if it's unspecified otherwise
protocol-neutral matches will have wrong information (e.g. NFPROTO_UNSPEC).
In preparation for using NFPROTO_UNSPEC xt matches.

v2: set the nfproto only when unspecified
Suggested-by: default avatarEyal Birger <eyal.birger@gmail.com>
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e10edd7
...@@ -182,6 +182,7 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em, ...@@ -182,6 +182,7 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em,
const struct em_ipt_match *im = (const void *)em->data; const struct em_ipt_match *im = (const void *)em->data;
struct xt_action_param acpar = {}; struct xt_action_param acpar = {};
struct net_device *indev = NULL; struct net_device *indev = NULL;
u8 nfproto = im->match->family;
struct nf_hook_state state; struct nf_hook_state state;
int ret; int ret;
...@@ -189,10 +190,14 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em, ...@@ -189,10 +190,14 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em,
case htons(ETH_P_IP): case htons(ETH_P_IP):
if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
return 0; return 0;
if (nfproto == NFPROTO_UNSPEC)
nfproto = NFPROTO_IPV4;
break; break;
case htons(ETH_P_IPV6): case htons(ETH_P_IPV6):
if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
return 0; return 0;
if (nfproto == NFPROTO_UNSPEC)
nfproto = NFPROTO_IPV6;
break; break;
default: default:
return 0; return 0;
...@@ -203,7 +208,7 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em, ...@@ -203,7 +208,7 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em,
if (skb->skb_iif) if (skb->skb_iif)
indev = dev_get_by_index_rcu(em->net, skb->skb_iif); indev = dev_get_by_index_rcu(em->net, skb->skb_iif);
nf_hook_state_init(&state, im->hook, im->match->family, nf_hook_state_init(&state, im->hook, nfproto,
indev ?: skb->dev, skb->dev, NULL, em->net, NULL); indev ?: skb->dev, skb->dev, NULL, em->net, NULL);
acpar.match = im->match; acpar.match = im->match;
......
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