Skip to content

Commit a2e2ff5

Browse files
David Aherndavem330
authored andcommitted
net: ipv6: Move ip6_route_get_saddr to inline
VRF driver needs access to ip6_route_get_saddr code. Since it does little beyond ipv6_dev_get_saddr and ipv6_dev_get_saddr is already exported for modules move ip6_route_get_saddr to the header as an inline. Code move only; no functional change. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0023a06 commit a2e2ff5

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

‎include/net/ip6_route.h‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct route_info {
1818
__u8 prefix[0]; /* 0,8 or 16 */
1919
};
2020

21+
#include <net/addrconf.h>
2122
#include <net/flow.h>
2223
#include <net/ip6_fib.h>
2324
#include <net/sock.h>
@@ -88,9 +89,23 @@ int ip6_route_add(struct fib6_config *cfg);
8889
int ip6_ins_rt(struct rt6_info *);
8990
int ip6_del_rt(struct rt6_info *);
9091

91-
int ip6_route_get_saddr(struct net *net, struct rt6_info *rt,
92-
const struct in6_addr *daddr, unsigned int prefs,
93-
struct in6_addr *saddr);
92+
static inline int ip6_route_get_saddr(struct net *net, struct rt6_info *rt,
93+
const struct in6_addr *daddr,
94+
unsigned int prefs,
95+
struct in6_addr *saddr)
96+
{
97+
struct inet6_dev *idev =
98+
rt ? ip6_dst_idev((struct dst_entry *)rt) : NULL;
99+
int err = 0;
100+
101+
if (rt && rt->rt6i_prefsrc.plen)
102+
*saddr = rt->rt6i_prefsrc.addr;
103+
else
104+
err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
105+
daddr, prefs, saddr);
106+
107+
return err;
108+
}
94109

95110
struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr,
96111
const struct in6_addr *saddr, int oif, int flags);

‎net/ipv6/route.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,23 +2586,6 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
25862586
return rt;
25872587
}
25882588

2589-
int ip6_route_get_saddr(struct net *net,
2590-
struct rt6_info *rt,
2591-
const struct in6_addr *daddr,
2592-
unsigned int prefs,
2593-
struct in6_addr *saddr)
2594-
{
2595-
struct inet6_dev *idev =
2596-
rt ? ip6_dst_idev((struct dst_entry *)rt) : NULL;
2597-
int err = 0;
2598-
if (rt && rt->rt6i_prefsrc.plen)
2599-
*saddr = rt->rt6i_prefsrc.addr;
2600-
else
2601-
err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
2602-
daddr, prefs, saddr);
2603-
return err;
2604-
}
2605-
26062589
/* remove deleted ip from prefsrc entries */
26072590
struct arg_dev_net_ip {
26082591
struct net_device *dev;

0 commit comments

Comments
 (0)