]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gre: Drop ip_route_output_gre().
authorGuillaume Nault <gnault@redhat.com>
Wed, 18 Dec 2024 13:17:16 +0000 (14:17 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 20 Dec 2024 03:24:47 +0000 (19:24 -0800)
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 <gnault@redhat.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://patch.msgid.link/ab7cba47b8558cd4bfe2dc843c38b622a95ee48e.1734527729.git.gnault@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/route.h
net/ipv4/ip_gre.c

index 84cb1e04f5cd9c2a9d35a53ee2081042b5b8a8d0..6947a155d50117e1b08705f2baae56073c0c6aaf 100644 (file)
@@ -185,20 +185,6 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct flowi
        return ip_route_output_flow(net, fl4, sk);
 }
 
-static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4 *fl4,
-                                                __be32 daddr, __be32 saddr,
-                                                __be32 gre_key, __u8 tos, int oif)
-{
-       memset(fl4, 0, sizeof(*fl4));
-       fl4->flowi4_oif = oif;
-       fl4->daddr = daddr;
-       fl4->saddr = saddr;
-       fl4->flowi4_tos = tos;
-       fl4->flowi4_proto = IPPROTO_GRE;
-       fl4->fl4_gre_key = gre_key;
-       return ip_route_output_key(net, fl4);
-}
-
 enum skb_drop_reason
 ip_mc_validate_source(struct sk_buff *skb, __be32 daddr, __be32 saddr,
                      dscp_t dscp, struct net_device *dev,
index f1f31ebfc7934467fd10776c3cb221f9cff9f9dd..a020342f618d6141f0e8a00fcb4bfabaf2f248bd 100644 (file)
@@ -924,15 +924,18 @@ static int ipgre_open(struct net_device *dev)
        struct ip_tunnel *t = netdev_priv(dev);
 
        if (ipv4_is_multicast(t->parms.iph.daddr)) {
-               struct flowi4 fl4;
+               struct flowi4 fl4 = {
+                       .flowi4_oif = t->parms.link,
+                       .flowi4_tos = t->parms.iph.tos & INET_DSCP_MASK,
+                       .flowi4_scope = RT_SCOPE_UNIVERSE,
+                       .flowi4_proto = IPPROTO_GRE,
+                       .saddr = t->parms.iph.saddr,
+                       .daddr = t->parms.iph.daddr,
+                       .fl4_gre_key = t->parms.o_key,
+               };
                struct rtable *rt;
 
-               rt = ip_route_output_gre(t->net, &fl4,
-                                        t->parms.iph.daddr,
-                                        t->parms.iph.saddr,
-                                        t->parms.o_key,
-                                        t->parms.iph.tos & INET_DSCP_MASK,
-                                        t->parms.link);
+               rt = ip_route_output_key(t->net, &fl4);
                if (IS_ERR(rt))
                        return -EADDRNOTAVAIL;
                dev = rt->dst.dev;