Skip to content

Commit 58189ca

Browse files
David Aherndavem330
authored andcommitted
net: Fix vti use case with oif in dst lookups
Steffen reported that the recent change to add oif to dst lookups breaks the VTI use case. The problem is that with the oif set in the flow struct the comparison to the nh_oif is triggered. Fix by splitting the FLOWI_FLAG_VRFSRC into 2 flags -- one that triggers the vrf device cache bypass (FLOWI_FLAG_VRFSRC) and another telling the lookup to not compare nh oif (FLOWI_FLAG_SKIP_NH_OIF). Fixes: 42a7b32 ("xfrm: Add oif to dst lookups") Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d828755 commit 58189ca

File tree

6 files changed

+9
-4
lines changed

6 files changed

+9
-4
lines changed

drivers/net/vrf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb,
193193
.flowi4_oif = vrf_dev->ifindex,
194194
.flowi4_iif = LOOPBACK_IFINDEX,
195195
.flowi4_tos = RT_TOS(ip4h->tos),
196-
.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC,
196+
.flowi4_flags = FLOWI_FLAG_ANYSRC | FLOWI_FLAG_VRFSRC |
197+
FLOWI_FLAG_SKIP_NH_OIF,
197198
.daddr = ip4h->daddr,
198199
};
199200

include/net/flow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct flowi_common {
3535
#define FLOWI_FLAG_ANYSRC 0x01
3636
#define FLOWI_FLAG_KNOWN_NH 0x02
3737
#define FLOWI_FLAG_VRFSRC 0x04
38+
#define FLOWI_FLAG_SKIP_NH_OIF 0x08
3839
__u32 flowic_secid;
3940
struct flowi_tunnel flowic_tun_key;
4041
};

include/net/route.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32
255255
flow_flags |= FLOWI_FLAG_ANYSRC;
256256

257257
if (netif_index_is_vrf(sock_net(sk), oif))
258-
flow_flags |= FLOWI_FLAG_VRFSRC;
258+
flow_flags |= FLOWI_FLAG_VRFSRC | FLOWI_FLAG_SKIP_NH_OIF;
259259

260260
flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE,
261261
protocol, flow_flags, dst, src, dport, sport);

net/ipv4/fib_trie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
14261426
nh->nh_flags & RTNH_F_LINKDOWN &&
14271427
!(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE))
14281428
continue;
1429-
if (!(flp->flowi4_flags & FLOWI_FLAG_VRFSRC)) {
1429+
if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) {
14301430
if (flp->flowi4_oif &&
14311431
flp->flowi4_oif != nh->nh_oif)
14321432
continue;

net/ipv4/udp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,8 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
10241024
if (netif_index_is_vrf(net, ipc.oif)) {
10251025
flowi4_init_output(fl4, ipc.oif, sk->sk_mark, tos,
10261026
RT_SCOPE_UNIVERSE, sk->sk_protocol,
1027-
(flow_flags | FLOWI_FLAG_VRFSRC),
1027+
(flow_flags | FLOWI_FLAG_VRFSRC |
1028+
FLOWI_FLAG_SKIP_NH_OIF),
10281029
faddr, saddr, dport,
10291030
inet->inet_sport);
10301031

net/ipv4/xfrm4_policy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4,
3333
if (saddr)
3434
fl4->saddr = saddr->a4;
3535

36+
fl4->flowi4_flags = FLOWI_FLAG_SKIP_NH_OIF;
37+
3638
rt = __ip_route_output_key(net, fl4);
3739
if (!IS_ERR(rt))
3840
return &rt->dst;

0 commit comments

Comments
 (0)