ipv6: Optmize translation between IPV6_PREFER_SRC_xxx and RT6_LOOKUP_F_xxx.
IPV6_PREFER_SRC_xxx definitions: | #define IPV6_PREFER_SRC_TMP 0x0001 | #define IPV6_PREFER_SRC_PUBLIC 0x0002 | #define IPV6_PREFER_SRC_COA 0x0004 RT6_LOOKUP_F_xxx definitions: | #define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008 | #define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010 | #define RT6_LOOKUP_F_SRCPREF_COA 0x00000020 So, we can translate between these two groups by shift operation instead of multiple 'if's. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
25dc27d17d
commit
0c9a2ac1f8
@@ -819,15 +819,8 @@ struct dst_entry * ip6_route_output(struct net *net, struct sock *sk,
|
||||
|
||||
if (!ipv6_addr_any(&fl->fl6_src))
|
||||
flags |= RT6_LOOKUP_F_HAS_SADDR;
|
||||
else if (sk) {
|
||||
unsigned int prefs = inet6_sk(sk)->srcprefs;
|
||||
if (prefs & IPV6_PREFER_SRC_TMP)
|
||||
flags |= RT6_LOOKUP_F_SRCPREF_TMP;
|
||||
if (prefs & IPV6_PREFER_SRC_PUBLIC)
|
||||
flags |= RT6_LOOKUP_F_SRCPREF_PUBLIC;
|
||||
if (prefs & IPV6_PREFER_SRC_COA)
|
||||
flags |= RT6_LOOKUP_F_SRCPREF_COA;
|
||||
}
|
||||
else if (sk)
|
||||
flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs);
|
||||
|
||||
return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output);
|
||||
}
|
||||
|
Reference in New Issue
Block a user