Skip to content

Commit

Permalink
net: sched: em_ipt: set the family based on the packet if it's unspec…
Browse files Browse the repository at this point in the history
…ified

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: Eyal Birger <eyal.birger@gmail.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and David S. Miller committed Jun 29, 2019
1 parent 9e10edd commit f4c1c40
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/sched/em_ipt.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,22 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em,
const struct em_ipt_match *im = (const void *)em->data;
struct xt_action_param acpar = {};
struct net_device *indev = NULL;
u8 nfproto = im->match->family;
struct nf_hook_state state;
int ret;

switch (tc_skb_protocol(skb)) {
case htons(ETH_P_IP):
if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
return 0;
if (nfproto == NFPROTO_UNSPEC)
nfproto = NFPROTO_IPV4;
break;
case htons(ETH_P_IPV6):
if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
return 0;
if (nfproto == NFPROTO_UNSPEC)
nfproto = NFPROTO_IPV6;
break;
default:
return 0;
Expand All @@ -203,7 +208,7 @@ static int em_ipt_match(struct sk_buff *skb, struct tcf_ematch *em,
if (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);

acpar.match = im->match;
Expand Down

0 comments on commit f4c1c40

Please sign in to comment.