Skip to content

Commit 29b5407

Browse files
Guillaume Naultkuba-moo
authored andcommitted
gre: Drop ip_route_output_gre().
We already have enough variants of ip_route_output*() functions. We don't need a GRE specific one in the generic route.h header file. Furthermore, ip_route_output_gre() is only used once, in ipgre_open(), where it can be easily replaced by a simple call to ip_route_output_key(). While there, and for clarity, explicitly set .flowi4_scope to RT_SCOPE_UNIVERSE instead of relying on the implicit zero initialisation. Signed-off-by: Guillaume Nault <[email protected]> Reviewed-by: Michal Swiatkowski <[email protected]> Link: https://patch.msgid.link/ab7cba47b8558cd4bfe2dc843c38b622a95ee48e.1734527729.git.gnault@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5155cbc commit 29b5407

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

include/net/route.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,6 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct flowi
185185
return ip_route_output_flow(net, fl4, sk);
186186
}
187187

188-
static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4 *fl4,
189-
__be32 daddr, __be32 saddr,
190-
__be32 gre_key, __u8 tos, int oif)
191-
{
192-
memset(fl4, 0, sizeof(*fl4));
193-
fl4->flowi4_oif = oif;
194-
fl4->daddr = daddr;
195-
fl4->saddr = saddr;
196-
fl4->flowi4_tos = tos;
197-
fl4->flowi4_proto = IPPROTO_GRE;
198-
fl4->fl4_gre_key = gre_key;
199-
return ip_route_output_key(net, fl4);
200-
}
201-
202188
enum skb_drop_reason
203189
ip_mc_validate_source(struct sk_buff *skb, __be32 daddr, __be32 saddr,
204190
dscp_t dscp, struct net_device *dev,

net/ipv4/ip_gre.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,15 +924,18 @@ static int ipgre_open(struct net_device *dev)
924924
struct ip_tunnel *t = netdev_priv(dev);
925925

926926
if (ipv4_is_multicast(t->parms.iph.daddr)) {
927-
struct flowi4 fl4;
927+
struct flowi4 fl4 = {
928+
.flowi4_oif = t->parms.link,
929+
.flowi4_tos = t->parms.iph.tos & INET_DSCP_MASK,
930+
.flowi4_scope = RT_SCOPE_UNIVERSE,
931+
.flowi4_proto = IPPROTO_GRE,
932+
.saddr = t->parms.iph.saddr,
933+
.daddr = t->parms.iph.daddr,
934+
.fl4_gre_key = t->parms.o_key,
935+
};
928936
struct rtable *rt;
929937

930-
rt = ip_route_output_gre(t->net, &fl4,
931-
t->parms.iph.daddr,
932-
t->parms.iph.saddr,
933-
t->parms.o_key,
934-
t->parms.iph.tos & INET_DSCP_MASK,
935-
t->parms.link);
938+
rt = ip_route_output_key(t->net, &fl4);
936939
if (IS_ERR(rt))
937940
return -EADDRNOTAVAIL;
938941
dev = rt->dst.dev;

0 commit comments

Comments
 (0)