Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IPV6] ADDRCONF: Allow address selection policy with ifindex.

This patch allows ifindex to be a key for address selection policy table.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

YOSHIFUJI Hideaki and committed by
David S. Miller
303065a8 c1ee656c

+8 -4
+8 -4
net/ipv6/addrconf.c
··· 875 875 } 876 876 877 877 /* static matching label */ 878 - static inline int ipv6_addr_label(const struct in6_addr *addr, int type) 878 + static inline int ipv6_addr_label(const struct in6_addr *addr, int type, 879 + int ifindex) 879 880 { 880 881 /* 881 882 * prefix (longest match) label ··· 911 910 struct inet6_ifaddr *ifa_result = NULL; 912 911 int daddr_type = __ipv6_addr_type(daddr); 913 912 int daddr_scope = __ipv6_addr_src_scope(daddr_type); 914 - u32 daddr_label = ipv6_addr_label(daddr, daddr_type); 913 + int daddr_ifindex = daddr_dev ? daddr_dev->ifindex : 0; 914 + u32 daddr_label = ipv6_addr_label(daddr, daddr_type, daddr_ifindex); 915 915 struct net_device *dev; 916 916 917 917 memset(&hiscore, 0, sizeof(hiscore)); ··· 1086 1084 /* Rule 6: Prefer matching label */ 1087 1085 if (hiscore.rule < 6) { 1088 1086 if (ipv6_addr_label(&ifa_result->addr, 1089 - hiscore.addr_type) == daddr_label) 1087 + hiscore.addr_type, 1088 + ifa_result->idev->dev->ifindex) == daddr_label) 1090 1089 hiscore.attrs |= IPV6_SADDR_SCORE_LABEL; 1091 1090 hiscore.rule++; 1092 1091 } 1093 1092 if (ipv6_addr_label(&ifa->addr, 1094 - score.addr_type) == daddr_label) { 1093 + score.addr_type, 1094 + ifa->idev->dev->ifindex) == daddr_label) { 1095 1095 score.attrs |= IPV6_SADDR_SCORE_LABEL; 1096 1096 if (!(hiscore.attrs & IPV6_SADDR_SCORE_LABEL)) { 1097 1097 score.rule = 6;