Skip to content

Commit 24b711e

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: Fix linklocal to global address with VRF
Example setup: host: ip -6 addr add dev eth1 2001:db8:104::4 where eth1 is enslaved to a VRF switch: ip -6 ro add 2001:db8:104::4/128 dev br1 where br1 only has an LLA ping6 2001:db8:104::4 ssh 2001:db8:104::4 (NOTE: UDP works fine if the PKTINFO has the address set to the global address and ifindex is set to the index of eth1 with a destination an LLA). For ICMP, icmp6_iif needs to be updated to check if skb->dev is an L3 master. If it is then return the ifindex from rt6i_idev similar to what is done for loopback. For TCP, restore the original tcp_v6_iif definition which is needed in most places and add a new tcp_v6_iif_l3_slave that considers the l3_slave variability. This latter check is only needed for socket lookups. Fixes: 9ff7438 ("net: vrf: Handle ipv6 multicast and link-local addresses") Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f95de8a commit 24b711e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

include/net/tcp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,11 @@ static inline void bpf_compute_data_end_sk_skb(struct sk_buff *skb)
840840
* as TCP moves IP6CB into a different location in skb->cb[]
841841
*/
842842
static inline int tcp_v6_iif(const struct sk_buff *skb)
843+
{
844+
return TCP_SKB_CB(skb)->header.h6.iif;
845+
}
846+
847+
static inline int tcp_v6_iif_l3_slave(const struct sk_buff *skb)
843848
{
844849
bool l3_slave = ipv6_l3mdev_skb(TCP_SKB_CB(skb)->header.h6.flags);
845850

net/ipv6/icmp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,10 @@ static int icmp6_iif(const struct sk_buff *skb)
402402

403403
/* for local traffic to local address, skb dev is the loopback
404404
* device. Check if there is a dst attached to the skb and if so
405-
* get the real device index.
405+
* get the real device index. Same is needed for replies to a link
406+
* local address on a device enslaved to an L3 master device
406407
*/
407-
if (unlikely(iif == LOOPBACK_IFINDEX)) {
408+
if (unlikely(iif == LOOPBACK_IFINDEX || netif_is_l3_master(skb->dev))) {
408409
const struct rt6_info *rt6 = skb_rt6_info(skb);
409410

410411
if (rt6)

net/ipv6/tcp_ipv6.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,8 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)
938938
&tcp_hashinfo, NULL, 0,
939939
&ipv6h->saddr,
940940
th->source, &ipv6h->daddr,
941-
ntohs(th->source), tcp_v6_iif(skb),
941+
ntohs(th->source),
942+
tcp_v6_iif_l3_slave(skb),
942943
tcp_v6_sdif(skb));
943944
if (!sk1)
944945
goto out;
@@ -1609,7 +1610,8 @@ static int tcp_v6_rcv(struct sk_buff *skb)
16091610
skb, __tcp_hdrlen(th),
16101611
&ipv6_hdr(skb)->saddr, th->source,
16111612
&ipv6_hdr(skb)->daddr,
1612-
ntohs(th->dest), tcp_v6_iif(skb),
1613+
ntohs(th->dest),
1614+
tcp_v6_iif_l3_slave(skb),
16131615
sdif);
16141616
if (sk2) {
16151617
struct inet_timewait_sock *tw = inet_twsk(sk);

0 commit comments

Comments
 (0)