diff options
author | Benjamin Thery <benjamin.thery@bull.net> | 2008-05-28 08:51:24 -0400 |
---|---|---|
committer | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2008-06-11 13:38:15 -0400 |
commit | 3de232554a91adc74e80dc15c304be806bd7e1f9 (patch) | |
tree | 625e86cdef1763c886e676132b235b1ba52068b4 /net/ipv6/addrconf.c | |
parent | 2b5ead46442d80928cce987ae6acf3fe99968ad8 (diff) |
ipv6 netns: Address labels per namespace
This pacth makes IPv6 address labels per network namespace.
It keeps the global label tables, ip6addrlbl_table, but
adds a 'net' member to each ip6addrlbl_entry.
This new member is taken into account when matching labels.
Changelog
=========
* v1: Initial version
* v2:
* Minize the penalty when network namespaces are not configured:
* the 'net' member is added only if CONFIG_NET_NS is
defined. This saves space when network namespaces are not
configured.
* 'net' value is retrieved with the inlined function
ip6addrlbl_net() that always return &init_net when
CONFIG_NET_NS is not defined.
* 'net' member in ip6addrlbl_entry renamed to the less generic
'lbl_net' name (helps code search).
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r-- | net/ipv6/addrconf.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 9ea4e62741ee..fa43374e85c5 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -964,7 +964,8 @@ static inline int ipv6_saddr_preferred(int type) | |||
964 | return 0; | 964 | return 0; |
965 | } | 965 | } |
966 | 966 | ||
967 | static int ipv6_get_saddr_eval(struct ipv6_saddr_score *score, | 967 | static int ipv6_get_saddr_eval(struct net *net, |
968 | struct ipv6_saddr_score *score, | ||
968 | struct ipv6_saddr_dst *dst, | 969 | struct ipv6_saddr_dst *dst, |
969 | int i) | 970 | int i) |
970 | { | 971 | { |
@@ -1043,7 +1044,8 @@ static int ipv6_get_saddr_eval(struct ipv6_saddr_score *score, | |||
1043 | break; | 1044 | break; |
1044 | case IPV6_SADDR_RULE_LABEL: | 1045 | case IPV6_SADDR_RULE_LABEL: |
1045 | /* Rule 6: Prefer matching label */ | 1046 | /* Rule 6: Prefer matching label */ |
1046 | ret = ipv6_addr_label(&score->ifa->addr, score->addr_type, | 1047 | ret = ipv6_addr_label(net, |
1048 | &score->ifa->addr, score->addr_type, | ||
1047 | score->ifa->idev->dev->ifindex) == dst->label; | 1049 | score->ifa->idev->dev->ifindex) == dst->label; |
1048 | break; | 1050 | break; |
1049 | #ifdef CONFIG_IPV6_PRIVACY | 1051 | #ifdef CONFIG_IPV6_PRIVACY |
@@ -1097,7 +1099,7 @@ int ipv6_dev_get_saddr(struct net_device *dst_dev, | |||
1097 | dst.addr = daddr; | 1099 | dst.addr = daddr; |
1098 | dst.ifindex = dst_dev ? dst_dev->ifindex : 0; | 1100 | dst.ifindex = dst_dev ? dst_dev->ifindex : 0; |
1099 | dst.scope = __ipv6_addr_src_scope(dst_type); | 1101 | dst.scope = __ipv6_addr_src_scope(dst_type); |
1100 | dst.label = ipv6_addr_label(daddr, dst_type, dst.ifindex); | 1102 | dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex); |
1101 | dst.prefs = prefs; | 1103 | dst.prefs = prefs; |
1102 | 1104 | ||
1103 | hiscore->rule = -1; | 1105 | hiscore->rule = -1; |
@@ -1165,8 +1167,8 @@ int ipv6_dev_get_saddr(struct net_device *dst_dev, | |||
1165 | for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) { | 1167 | for (i = 0; i < IPV6_SADDR_RULE_MAX; i++) { |
1166 | int minihiscore, miniscore; | 1168 | int minihiscore, miniscore; |
1167 | 1169 | ||
1168 | minihiscore = ipv6_get_saddr_eval(hiscore, &dst, i); | 1170 | minihiscore = ipv6_get_saddr_eval(net, hiscore, &dst, i); |
1169 | miniscore = ipv6_get_saddr_eval(score, &dst, i); | 1171 | miniscore = ipv6_get_saddr_eval(net, score, &dst, i); |
1170 | 1172 | ||
1171 | if (minihiscore > miniscore) { | 1173 | if (minihiscore > miniscore) { |
1172 | if (i == IPV6_SADDR_RULE_SCOPE && | 1174 | if (i == IPV6_SADDR_RULE_SCOPE && |