Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 187960
b: refs/heads/master
c: 0c9a2ac
h: refs/heads/master
v: v3
  • Loading branch information
YOSHIFUJI Hideaki / 吉藤英明 authored and David S. Miller committed Mar 7, 2010
1 parent 6158374 commit c329605
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 25dc27d17dc868aae78fd03bef3113cf586b12e5
refs/heads/master: 0c9a2ac1f8a2e55b3382dfc27256878a58ea49e9
18 changes: 18 additions & 0 deletions trunk/include/net/ip6_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ struct route_info {
#define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010
#define RT6_LOOKUP_F_SRCPREF_COA 0x00000020

/*
* rt6_srcprefs2flags() and rt6_flags2srcprefs() translate
* between IPV6_ADDR_PREFERENCES socket option values
* IPV6_PREFER_SRC_TMP = 0x1
* IPV6_PREFER_SRC_PUBLIC = 0x2
* IPV6_PREFER_SRC_COA = 0x4
* and above RT6_LOOKUP_F_SRCPREF_xxx flags.
*/
static inline int rt6_srcprefs2flags(unsigned int srcprefs)
{
/* No need to bitmask because srcprefs have only 3 bits. */
return srcprefs << 3;
}

static inline unsigned int rt6_flags2srcprefs(int flags)
{
return (flags >> 3) & 7;
}

extern void ip6_route_input(struct sk_buff *skb);

Expand Down
11 changes: 2 additions & 9 deletions trunk/net/ipv6/fib6_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,11 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
if ((rule->flags & FIB_RULE_FIND_SADDR) &&
r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) {
struct in6_addr saddr;
unsigned int srcprefs = 0;

if (flags & RT6_LOOKUP_F_SRCPREF_TMP)
srcprefs |= IPV6_PREFER_SRC_TMP;
if (flags & RT6_LOOKUP_F_SRCPREF_PUBLIC)
srcprefs |= IPV6_PREFER_SRC_PUBLIC;
if (flags & RT6_LOOKUP_F_SRCPREF_COA)
srcprefs |= IPV6_PREFER_SRC_COA;

if (ipv6_dev_get_saddr(net,
ip6_dst_idev(&rt->u.dst)->dev,
&flp->fl6_dst, srcprefs,
&flp->fl6_dst,
rt6_flags2srcprefs(flags),
&saddr))
goto again;
if (!ipv6_prefix_equal(&saddr, &r->src.addr,
Expand Down
11 changes: 2 additions & 9 deletions trunk/net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c329605

Please sign in to comment.