aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2018-05-16 16:36:40 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-17 14:55:21 -0400
commit5a847a6e1477be5bd3f94cc1b7708d7d4a7cd94c (patch)
treef115003a688ee3366207745a53eabbe53a533796
parent8ab6ffba14a466c7298cb3fd5066d774d2977ad1 (diff)
net/ipv4: Initialize proto and ports in flow struct
Updating the FIB tracepoint for the recent change to allow rules using the protocol and ports exposed a few places where the entries in the flow struct are not initialized. For __fib_validate_source add the call to fib4_rules_early_flow_dissect since it is invoked for the input path. For netfilter, add the memset on the flow struct to avoid future problems like this. In ip_route_input_slow need to set the fields if the skb dissection does not happen. Fixes: bfff4862653b ("net: fib_rules: support for match on ip_proto, sport and dport") Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/fib_frontend.c8
-rw-r--r--net/ipv4/netfilter/ipt_rpfilter.c2
-rw-r--r--net/ipv4/route.c7
3 files changed, 14 insertions, 3 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index f05afaf3235c..4d622112bf95 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -326,10 +326,11 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
326 u8 tos, int oif, struct net_device *dev, 326 u8 tos, int oif, struct net_device *dev,
327 int rpf, struct in_device *idev, u32 *itag) 327 int rpf, struct in_device *idev, u32 *itag)
328{ 328{
329 struct net *net = dev_net(dev);
330 struct flow_keys flkeys;
329 int ret, no_addr; 331 int ret, no_addr;
330 struct fib_result res; 332 struct fib_result res;
331 struct flowi4 fl4; 333 struct flowi4 fl4;
332 struct net *net = dev_net(dev);
333 bool dev_match; 334 bool dev_match;
334 335
335 fl4.flowi4_oif = 0; 336 fl4.flowi4_oif = 0;
@@ -347,6 +348,11 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
347 no_addr = idev->ifa_list == NULL; 348 no_addr = idev->ifa_list == NULL;
348 349
349 fl4.flowi4_mark = IN_DEV_SRC_VMARK(idev) ? skb->mark : 0; 350 fl4.flowi4_mark = IN_DEV_SRC_VMARK(idev) ? skb->mark : 0;
351 if (!fib4_rules_early_flow_dissect(net, skb, &fl4, &flkeys)) {
352 fl4.flowi4_proto = 0;
353 fl4.fl4_sport = 0;
354 fl4.fl4_dport = 0;
355 }
350 356
351 trace_fib_validate_source(dev, &fl4); 357 trace_fib_validate_source(dev, &fl4);
352 358
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index fd01f13c896a..12843c9ef142 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -89,10 +89,10 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
89 return true ^ invert; 89 return true ^ invert;
90 } 90 }
91 91
92 memset(&flow, 0, sizeof(flow));
92 flow.flowi4_iif = LOOPBACK_IFINDEX; 93 flow.flowi4_iif = LOOPBACK_IFINDEX;
93 flow.daddr = iph->saddr; 94 flow.daddr = iph->saddr;
94 flow.saddr = rpfilter_get_saddr(iph->daddr); 95 flow.saddr = rpfilter_get_saddr(iph->daddr);
95 flow.flowi4_oif = 0;
96 flow.flowi4_mark = info->flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0; 96 flow.flowi4_mark = info->flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0;
97 flow.flowi4_tos = RT_TOS(iph->tos); 97 flow.flowi4_tos = RT_TOS(iph->tos);
98 flow.flowi4_scope = RT_SCOPE_UNIVERSE; 98 flow.flowi4_scope = RT_SCOPE_UNIVERSE;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 29268efad247..2cfa1b518f8d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1961,8 +1961,13 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1961 fl4.saddr = saddr; 1961 fl4.saddr = saddr;
1962 fl4.flowi4_uid = sock_net_uid(net, NULL); 1962 fl4.flowi4_uid = sock_net_uid(net, NULL);
1963 1963
1964 if (fib4_rules_early_flow_dissect(net, skb, &fl4, &_flkeys)) 1964 if (fib4_rules_early_flow_dissect(net, skb, &fl4, &_flkeys)) {
1965 flkeys = &_flkeys; 1965 flkeys = &_flkeys;
1966 } else {
1967 fl4.flowi4_proto = 0;
1968 fl4.fl4_sport = 0;
1969 fl4.fl4_dport = 0;
1970 }
1966 1971
1967 err = fib_lookup(net, &fl4, res, 0); 1972 err = fib_lookup(net, &fl4, res, 0);
1968 if (err != 0) { 1973 if (err != 0) {