Skip to content

Commit 1d053da

Browse files
dsahernborkmann
authored andcommitted
net/ipv6: Extract table lookup from ip6_pol_route
ip6_pol_route is used for ingress and egress FIB lookups. Refactor it moving the table lookup into a separate fib6_table_lookup that can be invoked separately and export the new function. ip6_pol_route now calls fib6_table_lookup and uses the result to generate a dst based rt6_info. Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 3b290a3 commit 1d053da

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

include/net/ip6_fib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
376376
const struct sk_buff *skb,
377377
int flags, pol_lookup_t lookup);
378378

379+
/* called with rcu lock held; caller needs to select path */
380+
struct fib6_info *fib6_table_lookup(struct net *net, struct fib6_table *table,
381+
int oif, struct flowi6 *fl6, int strict);
382+
379383
struct fib6_info *fib6_multipath_select(const struct net *net,
380384
struct fib6_info *match,
381385
struct flowi6 *fl6, int oif,

net/ipv6/route.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,21 +1800,12 @@ void rt6_age_exceptions(struct fib6_info *rt,
18001800
rcu_read_unlock_bh();
18011801
}
18021802

1803-
struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
1804-
int oif, struct flowi6 *fl6,
1805-
const struct sk_buff *skb, int flags)
1803+
/* must be called with rcu lock held */
1804+
struct fib6_info *fib6_table_lookup(struct net *net, struct fib6_table *table,
1805+
int oif, struct flowi6 *fl6, int strict)
18061806
{
18071807
struct fib6_node *fn, *saved_fn;
18081808
struct fib6_info *f6i;
1809-
struct rt6_info *rt;
1810-
int strict = 0;
1811-
1812-
strict |= flags & RT6_LOOKUP_F_IFACE;
1813-
strict |= flags & RT6_LOOKUP_F_IGNORE_LINKSTATE;
1814-
if (net->ipv6.devconf_all->forwarding == 0)
1815-
strict |= RT6_LOOKUP_F_REACHABLE;
1816-
1817-
rcu_read_lock();
18181809

18191810
fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr);
18201811
saved_fn = fn;
@@ -1824,8 +1815,6 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
18241815

18251816
redo_rt6_select:
18261817
f6i = rt6_select(net, fn, oif, strict);
1827-
if (f6i->fib6_nsiblings)
1828-
f6i = fib6_multipath_select(net, f6i, fl6, oif, skb, strict);
18291818
if (f6i == net->ipv6.fib6_null_entry) {
18301819
fn = fib6_backtrack(fn, &fl6->saddr);
18311820
if (fn)
@@ -1838,6 +1827,28 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
18381827
}
18391828
}
18401829

1830+
return f6i;
1831+
}
1832+
1833+
struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
1834+
int oif, struct flowi6 *fl6,
1835+
const struct sk_buff *skb, int flags)
1836+
{
1837+
struct fib6_info *f6i;
1838+
struct rt6_info *rt;
1839+
int strict = 0;
1840+
1841+
strict |= flags & RT6_LOOKUP_F_IFACE;
1842+
strict |= flags & RT6_LOOKUP_F_IGNORE_LINKSTATE;
1843+
if (net->ipv6.devconf_all->forwarding == 0)
1844+
strict |= RT6_LOOKUP_F_REACHABLE;
1845+
1846+
rcu_read_lock();
1847+
1848+
f6i = fib6_table_lookup(net, table, oif, fl6, strict);
1849+
if (f6i->fib6_nsiblings)
1850+
f6i = fib6_multipath_select(net, f6i, fl6, oif, skb, strict);
1851+
18411852
if (f6i == net->ipv6.fib6_null_entry) {
18421853
rt = net->ipv6.ip6_null_entry;
18431854
rcu_read_unlock();

0 commit comments

Comments
 (0)