Skip to content

Commit a64b04d

Browse files
Jiri Bencdavem330
authored andcommitted
gre: do not assign header_ops in collect metadata mode
In ipgre mode (i.e. not gretap) with collect metadata flag set, the tunnel is incorrectly assumed to be mGRE in NBMA mode (see commit 6a5f44d). This is not the case, we're controlling the encapsulation addresses by lwtunnel metadata. And anyway, assigning dev->header_ops in collect metadata mode does not make sense. Although it would be more user firendly to reject requests that specify both the collect metadata flag and a remote/local IP address, this would break current users of gretap or introduce ugly code and differences in handling ipgre and gretap configuration. Keep the current behavior of remote/local IP address being ignored in such case. v3: Back to v1, added explanation paragraph. v2: Reject configuration specifying both remote/local address and collect metadata flag. Fixes: 2e15ea3 ("ip_gre: Add support to collect tunnel metadata.") Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 12395d0 commit a64b04d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv4/ip_gre.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
893893
netif_keep_dst(dev);
894894
dev->addr_len = 4;
895895

896-
if (iph->daddr) {
896+
if (iph->daddr && !tunnel->collect_md) {
897897
#ifdef CONFIG_NET_IPGRE_BROADCAST
898898
if (ipv4_is_multicast(iph->daddr)) {
899899
if (!iph->saddr)
@@ -902,8 +902,9 @@ static int ipgre_tunnel_init(struct net_device *dev)
902902
dev->header_ops = &ipgre_header_ops;
903903
}
904904
#endif
905-
} else
905+
} else if (!tunnel->collect_md) {
906906
dev->header_ops = &ipgre_header_ops;
907+
}
907908

908909
return ip_tunnel_init(dev);
909910
}

0 commit comments

Comments
 (0)