YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 1 | /* |
| 2 | * IPv6 Address Label subsystem |
| 3 | * for the IPv6 "Default" Source Address Selection |
| 4 | * |
| 5 | * Copyright (C)2007 USAGI/WIDE Project |
| 6 | */ |
| 7 | /* |
| 8 | * Author: |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 9 | * YOSHIFUJI Hideaki @ USAGI/WIDE Project <yoshfuji@linux-ipv6.org> |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/list.h> |
| 14 | #include <linux/rcupdate.h> |
| 15 | #include <linux/in6.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 17 | #include <net/addrconf.h> |
| 18 | #include <linux/if_addrlabel.h> |
| 19 | #include <linux/netlink.h> |
| 20 | #include <linux/rtnetlink.h> |
| 21 | |
| 22 | #if 0 |
| 23 | #define ADDRLABEL(x...) printk(x) |
| 24 | #else |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 25 | #define ADDRLABEL(x...) do { ; } while (0) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 26 | #endif |
| 27 | |
| 28 | /* |
| 29 | * Policy Table |
| 30 | */ |
Wang Yufen | 22b285d | 2014-02-17 16:53:33 +0800 | [diff] [blame] | 31 | struct ip6addrlbl_entry { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 32 | #ifdef CONFIG_NET_NS |
| 33 | struct net *lbl_net; |
| 34 | #endif |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 35 | struct in6_addr prefix; |
| 36 | int prefixlen; |
| 37 | int ifindex; |
| 38 | int addrtype; |
| 39 | u32 label; |
| 40 | struct hlist_node list; |
| 41 | atomic_t refcnt; |
| 42 | struct rcu_head rcu; |
| 43 | }; |
| 44 | |
| 45 | static struct ip6addrlbl_table |
| 46 | { |
| 47 | struct hlist_head head; |
| 48 | spinlock_t lock; |
| 49 | u32 seq; |
| 50 | } ip6addrlbl_table; |
| 51 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 52 | static inline |
| 53 | struct net *ip6addrlbl_net(const struct ip6addrlbl_entry *lbl) |
| 54 | { |
Eric Dumazet | c2d9ba9 | 2010-06-01 06:51:19 +0000 | [diff] [blame] | 55 | return read_pnet(&lbl->lbl_net); |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 56 | } |
| 57 | |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 58 | /* |
YOSHIFUJI Hideaki / 吉藤英明 | 417962a | 2012-09-10 18:16:49 +0000 | [diff] [blame] | 59 | * Default policy table (RFC6724 + extensions) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 60 | * |
| 61 | * prefix addr_type label |
| 62 | * ------------------------------------------------------------------------- |
| 63 | * ::1/128 LOOPBACK 0 |
| 64 | * ::/0 N/A 1 |
| 65 | * 2002::/16 N/A 2 |
| 66 | * ::/96 COMPATv4 3 |
| 67 | * ::ffff:0:0/96 V4MAPPED 4 |
| 68 | * fc00::/7 N/A 5 ULA (RFC 4193) |
| 69 | * 2001::/32 N/A 6 Teredo (RFC 4380) |
Juha-Matti Tapio | 5fe47b8 | 2008-02-28 20:55:02 -0800 | [diff] [blame] | 70 | * 2001:10::/28 N/A 7 ORCHID (RFC 4843) |
YOSHIFUJI Hideaki / 吉藤英明 | 417962a | 2012-09-10 18:16:49 +0000 | [diff] [blame] | 71 | * fec0::/10 N/A 11 Site-local |
| 72 | * (deprecated by RFC3879) |
| 73 | * 3ffe::/16 N/A 12 6bone |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 74 | * |
| 75 | * Note: 0xffffffff is used if we do not have any policies. |
YOSHIFUJI Hideaki / 吉藤英明 | 417962a | 2012-09-10 18:16:49 +0000 | [diff] [blame] | 76 | * Note: Labels for ULA and 6to4 are different from labels listed in RFC6724. |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 77 | */ |
| 78 | |
| 79 | #define IPV6_ADDR_LABEL_DEFAULT 0xffffffffUL |
| 80 | |
Andi Kleen | 04a6f82 | 2012-10-04 17:12:11 -0700 | [diff] [blame] | 81 | static const __net_initconst struct ip6addrlbl_init_table |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 82 | { |
| 83 | const struct in6_addr *prefix; |
| 84 | int prefixlen; |
| 85 | u32 label; |
| 86 | } ip6addrlbl_init_table[] = { |
| 87 | { /* ::/0 */ |
| 88 | .prefix = &in6addr_any, |
| 89 | .label = 1, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 90 | }, { /* fc00::/7 */ |
| 91 | .prefix = &(struct in6_addr){ { { 0xfc } } } , |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 92 | .prefixlen = 7, |
| 93 | .label = 5, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 94 | }, { /* fec0::/10 */ |
| 95 | .prefix = &(struct in6_addr){ { { 0xfe, 0xc0 } } }, |
YOSHIFUJI Hideaki / 吉藤英明 | 417962a | 2012-09-10 18:16:49 +0000 | [diff] [blame] | 96 | .prefixlen = 10, |
| 97 | .label = 11, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 98 | }, { /* 2002::/16 */ |
| 99 | .prefix = &(struct in6_addr){ { { 0x20, 0x02 } } }, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 100 | .prefixlen = 16, |
| 101 | .label = 2, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 102 | }, { /* 3ffe::/16 */ |
| 103 | .prefix = &(struct in6_addr){ { { 0x3f, 0xfe } } }, |
YOSHIFUJI Hideaki / 吉藤英明 | 417962a | 2012-09-10 18:16:49 +0000 | [diff] [blame] | 104 | .prefixlen = 16, |
| 105 | .label = 12, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 106 | }, { /* 2001::/32 */ |
| 107 | .prefix = &(struct in6_addr){ { { 0x20, 0x01 } } }, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 108 | .prefixlen = 32, |
| 109 | .label = 6, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 110 | }, { /* 2001:10::/28 */ |
| 111 | .prefix = &(struct in6_addr){ { { 0x20, 0x01, 0x00, 0x10 } } }, |
Juha-Matti Tapio | 5fe47b8 | 2008-02-28 20:55:02 -0800 | [diff] [blame] | 112 | .prefixlen = 28, |
| 113 | .label = 7, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 114 | }, { /* ::ffff:0:0 */ |
| 115 | .prefix = &(struct in6_addr){ { { [10] = 0xff, [11] = 0xff } } }, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 116 | .prefixlen = 96, |
| 117 | .label = 4, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 118 | }, { /* ::/96 */ |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 119 | .prefix = &in6addr_any, |
| 120 | .prefixlen = 96, |
| 121 | .label = 3, |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 122 | }, { /* ::1/128 */ |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 123 | .prefix = &in6addr_loopback, |
| 124 | .prefixlen = 128, |
| 125 | .label = 0, |
| 126 | } |
| 127 | }; |
| 128 | |
| 129 | /* Object management */ |
| 130 | static inline void ip6addrlbl_free(struct ip6addrlbl_entry *p) |
| 131 | { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 132 | #ifdef CONFIG_NET_NS |
| 133 | release_net(p->lbl_net); |
| 134 | #endif |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 135 | kfree(p); |
| 136 | } |
| 137 | |
YOSHIFUJI Hideaki | 85040bc | 2008-01-28 15:46:02 -0800 | [diff] [blame] | 138 | static void ip6addrlbl_free_rcu(struct rcu_head *h) |
| 139 | { |
| 140 | ip6addrlbl_free(container_of(h, struct ip6addrlbl_entry, rcu)); |
| 141 | } |
| 142 | |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 143 | static bool ip6addrlbl_hold(struct ip6addrlbl_entry *p) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 144 | { |
| 145 | return atomic_inc_not_zero(&p->refcnt); |
| 146 | } |
| 147 | |
| 148 | static inline void ip6addrlbl_put(struct ip6addrlbl_entry *p) |
| 149 | { |
| 150 | if (atomic_dec_and_test(&p->refcnt)) |
YOSHIFUJI Hideaki | 85040bc | 2008-01-28 15:46:02 -0800 | [diff] [blame] | 151 | call_rcu(&p->rcu, ip6addrlbl_free_rcu); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | /* Find label */ |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 155 | static bool __ip6addrlbl_match(struct net *net, |
| 156 | const struct ip6addrlbl_entry *p, |
| 157 | const struct in6_addr *addr, |
| 158 | int addrtype, int ifindex) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 159 | { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 160 | if (!net_eq(ip6addrlbl_net(p), net)) |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 161 | return false; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 162 | if (p->ifindex && p->ifindex != ifindex) |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 163 | return false; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 164 | if (p->addrtype && p->addrtype != addrtype) |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 165 | return false; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 166 | if (!ipv6_prefix_equal(addr, &p->prefix, p->prefixlen)) |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 167 | return false; |
| 168 | return true; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 169 | } |
| 170 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 171 | static struct ip6addrlbl_entry *__ipv6_addr_label(struct net *net, |
| 172 | const struct in6_addr *addr, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 173 | int type, int ifindex) |
| 174 | { |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 175 | struct ip6addrlbl_entry *p; |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 176 | hlist_for_each_entry_rcu(p, &ip6addrlbl_table.head, list) { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 177 | if (__ip6addrlbl_match(net, p, addr, type, ifindex)) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 178 | return p; |
| 179 | } |
| 180 | return NULL; |
| 181 | } |
| 182 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 183 | u32 ipv6_addr_label(struct net *net, |
| 184 | const struct in6_addr *addr, int type, int ifindex) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 185 | { |
| 186 | u32 label; |
| 187 | struct ip6addrlbl_entry *p; |
| 188 | |
| 189 | type &= IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK; |
| 190 | |
| 191 | rcu_read_lock(); |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 192 | p = __ipv6_addr_label(net, addr, type, ifindex); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 193 | label = p ? p->label : IPV6_ADDR_LABEL_DEFAULT; |
| 194 | rcu_read_unlock(); |
| 195 | |
Harvey Harrison | 5b095d989 | 2008-10-29 12:52:50 -0700 | [diff] [blame] | 196 | ADDRLABEL(KERN_DEBUG "%s(addr=%pI6, type=%d, ifindex=%d) => %08x\n", |
Harvey Harrison | 0c6ce78 | 2008-10-28 16:09:23 -0700 | [diff] [blame] | 197 | __func__, addr, type, ifindex, label); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 198 | |
| 199 | return label; |
| 200 | } |
| 201 | |
| 202 | /* allocate one entry */ |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 203 | static struct ip6addrlbl_entry *ip6addrlbl_alloc(struct net *net, |
| 204 | const struct in6_addr *prefix, |
YOSHIFUJI Hideaki | 40fee36 | 2008-01-22 17:12:50 +0900 | [diff] [blame] | 205 | int prefixlen, int ifindex, |
| 206 | u32 label) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 207 | { |
| 208 | struct ip6addrlbl_entry *newp; |
| 209 | int addrtype; |
| 210 | |
Harvey Harrison | 5b095d989 | 2008-10-29 12:52:50 -0700 | [diff] [blame] | 211 | ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u)\n", |
Harvey Harrison | 0c6ce78 | 2008-10-28 16:09:23 -0700 | [diff] [blame] | 212 | __func__, prefix, prefixlen, ifindex, (unsigned int)label); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 213 | |
| 214 | addrtype = ipv6_addr_type(prefix) & (IPV6_ADDR_MAPPED | IPV6_ADDR_COMPATv4 | IPV6_ADDR_LOOPBACK); |
| 215 | |
| 216 | switch (addrtype) { |
| 217 | case IPV6_ADDR_MAPPED: |
| 218 | if (prefixlen > 96) |
| 219 | return ERR_PTR(-EINVAL); |
| 220 | if (prefixlen < 96) |
| 221 | addrtype = 0; |
| 222 | break; |
| 223 | case IPV6_ADDR_COMPATv4: |
| 224 | if (prefixlen != 96) |
| 225 | addrtype = 0; |
| 226 | break; |
| 227 | case IPV6_ADDR_LOOPBACK: |
| 228 | if (prefixlen != 128) |
| 229 | addrtype = 0; |
| 230 | break; |
| 231 | } |
| 232 | |
| 233 | newp = kmalloc(sizeof(*newp), GFP_KERNEL); |
| 234 | if (!newp) |
| 235 | return ERR_PTR(-ENOMEM); |
| 236 | |
| 237 | ipv6_addr_prefix(&newp->prefix, prefix, prefixlen); |
| 238 | newp->prefixlen = prefixlen; |
| 239 | newp->ifindex = ifindex; |
| 240 | newp->addrtype = addrtype; |
| 241 | newp->label = label; |
| 242 | INIT_HLIST_NODE(&newp->list); |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 243 | #ifdef CONFIG_NET_NS |
| 244 | newp->lbl_net = hold_net(net); |
| 245 | #endif |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 246 | atomic_set(&newp->refcnt, 1); |
| 247 | return newp; |
| 248 | } |
| 249 | |
| 250 | /* add a label */ |
YOSHIFUJI Hideaki | 40fee36 | 2008-01-22 17:12:50 +0900 | [diff] [blame] | 251 | static int __ip6addrlbl_add(struct ip6addrlbl_entry *newp, int replace) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 252 | { |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 253 | struct hlist_node *n; |
| 254 | struct ip6addrlbl_entry *last = NULL, *p = NULL; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 255 | int ret = 0; |
| 256 | |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 257 | ADDRLABEL(KERN_DEBUG "%s(newp=%p, replace=%d)\n", __func__, newp, |
| 258 | replace); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 259 | |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 260 | hlist_for_each_entry_safe(p, n, &ip6addrlbl_table.head, list) { |
| 261 | if (p->prefixlen == newp->prefixlen && |
| 262 | net_eq(ip6addrlbl_net(p), ip6addrlbl_net(newp)) && |
| 263 | p->ifindex == newp->ifindex && |
| 264 | ipv6_addr_equal(&p->prefix, &newp->prefix)) { |
| 265 | if (!replace) { |
| 266 | ret = -EEXIST; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 267 | goto out; |
| 268 | } |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 269 | hlist_replace_rcu(&p->list, &newp->list); |
| 270 | ip6addrlbl_put(p); |
| 271 | goto out; |
| 272 | } else if ((p->prefixlen == newp->prefixlen && !p->ifindex) || |
| 273 | (p->prefixlen < newp->prefixlen)) { |
| 274 | hlist_add_before_rcu(&newp->list, &p->list); |
| 275 | goto out; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 276 | } |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 277 | last = p; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 278 | } |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 279 | if (last) |
Ken Helias | 1d02328 | 2014-08-06 16:09:16 -0700 | [diff] [blame] | 280 | hlist_add_behind_rcu(&newp->list, &last->list); |
Hannes Frederic Sowa | 639739b | 2013-09-03 02:13:31 +0200 | [diff] [blame] | 281 | else |
| 282 | hlist_add_head_rcu(&newp->list, &ip6addrlbl_table.head); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 283 | out: |
| 284 | if (!ret) |
| 285 | ip6addrlbl_table.seq++; |
| 286 | return ret; |
| 287 | } |
| 288 | |
| 289 | /* add a label */ |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 290 | static int ip6addrlbl_add(struct net *net, |
| 291 | const struct in6_addr *prefix, int prefixlen, |
YOSHIFUJI Hideaki | 40fee36 | 2008-01-22 17:12:50 +0900 | [diff] [blame] | 292 | int ifindex, u32 label, int replace) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 293 | { |
| 294 | struct ip6addrlbl_entry *newp; |
| 295 | int ret = 0; |
| 296 | |
Harvey Harrison | 5b095d989 | 2008-10-29 12:52:50 -0700 | [diff] [blame] | 297 | ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d, label=%u, replace=%d)\n", |
Harvey Harrison | 0c6ce78 | 2008-10-28 16:09:23 -0700 | [diff] [blame] | 298 | __func__, prefix, prefixlen, ifindex, (unsigned int)label, |
| 299 | replace); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 300 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 301 | newp = ip6addrlbl_alloc(net, prefix, prefixlen, ifindex, label); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 302 | if (IS_ERR(newp)) |
| 303 | return PTR_ERR(newp); |
| 304 | spin_lock(&ip6addrlbl_table.lock); |
| 305 | ret = __ip6addrlbl_add(newp, replace); |
| 306 | spin_unlock(&ip6addrlbl_table.lock); |
| 307 | if (ret) |
| 308 | ip6addrlbl_free(newp); |
| 309 | return ret; |
| 310 | } |
| 311 | |
| 312 | /* remove a label */ |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 313 | static int __ip6addrlbl_del(struct net *net, |
| 314 | const struct in6_addr *prefix, int prefixlen, |
YOSHIFUJI Hideaki | 40fee36 | 2008-01-22 17:12:50 +0900 | [diff] [blame] | 315 | int ifindex) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 316 | { |
| 317 | struct ip6addrlbl_entry *p = NULL; |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 318 | struct hlist_node *n; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 319 | int ret = -ESRCH; |
| 320 | |
Harvey Harrison | 5b095d989 | 2008-10-29 12:52:50 -0700 | [diff] [blame] | 321 | ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n", |
Harvey Harrison | 0c6ce78 | 2008-10-28 16:09:23 -0700 | [diff] [blame] | 322 | __func__, prefix, prefixlen, ifindex); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 323 | |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 324 | hlist_for_each_entry_safe(p, n, &ip6addrlbl_table.head, list) { |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 325 | if (p->prefixlen == prefixlen && |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 326 | net_eq(ip6addrlbl_net(p), net) && |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 327 | p->ifindex == ifindex && |
| 328 | ipv6_addr_equal(&p->prefix, prefix)) { |
| 329 | hlist_del_rcu(&p->list); |
| 330 | ip6addrlbl_put(p); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 331 | ret = 0; |
| 332 | break; |
| 333 | } |
| 334 | } |
| 335 | return ret; |
| 336 | } |
| 337 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 338 | static int ip6addrlbl_del(struct net *net, |
| 339 | const struct in6_addr *prefix, int prefixlen, |
YOSHIFUJI Hideaki | 40fee36 | 2008-01-22 17:12:50 +0900 | [diff] [blame] | 340 | int ifindex) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 341 | { |
| 342 | struct in6_addr prefix_buf; |
| 343 | int ret; |
| 344 | |
Harvey Harrison | 5b095d989 | 2008-10-29 12:52:50 -0700 | [diff] [blame] | 345 | ADDRLABEL(KERN_DEBUG "%s(prefix=%pI6, prefixlen=%d, ifindex=%d)\n", |
Harvey Harrison | 0c6ce78 | 2008-10-28 16:09:23 -0700 | [diff] [blame] | 346 | __func__, prefix, prefixlen, ifindex); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 347 | |
| 348 | ipv6_addr_prefix(&prefix_buf, prefix, prefixlen); |
| 349 | spin_lock(&ip6addrlbl_table.lock); |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 350 | ret = __ip6addrlbl_del(net, &prefix_buf, prefixlen, ifindex); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 351 | spin_unlock(&ip6addrlbl_table.lock); |
| 352 | return ret; |
| 353 | } |
| 354 | |
| 355 | /* add default label */ |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 356 | static int __net_init ip6addrlbl_net_init(struct net *net) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 357 | { |
| 358 | int err = 0; |
| 359 | int i; |
| 360 | |
Joe Perches | f321383 | 2012-05-15 14:11:53 +0000 | [diff] [blame] | 361 | ADDRLABEL(KERN_DEBUG "%s\n", __func__); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 362 | |
| 363 | for (i = 0; i < ARRAY_SIZE(ip6addrlbl_init_table); i++) { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 364 | int ret = ip6addrlbl_add(net, |
| 365 | ip6addrlbl_init_table[i].prefix, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 366 | ip6addrlbl_init_table[i].prefixlen, |
| 367 | 0, |
| 368 | ip6addrlbl_init_table[i].label, 0); |
| 369 | /* XXX: should we free all rules when we catch an error? */ |
| 370 | if (ret && (!err || err != -ENOMEM)) |
| 371 | err = ret; |
| 372 | } |
| 373 | return err; |
| 374 | } |
| 375 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 376 | static void __net_exit ip6addrlbl_net_exit(struct net *net) |
| 377 | { |
| 378 | struct ip6addrlbl_entry *p = NULL; |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 379 | struct hlist_node *n; |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 380 | |
| 381 | /* Remove all labels belonging to the exiting net */ |
| 382 | spin_lock(&ip6addrlbl_table.lock); |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 383 | hlist_for_each_entry_safe(p, n, &ip6addrlbl_table.head, list) { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 384 | if (net_eq(ip6addrlbl_net(p), net)) { |
| 385 | hlist_del_rcu(&p->list); |
| 386 | ip6addrlbl_put(p); |
| 387 | } |
| 388 | } |
| 389 | spin_unlock(&ip6addrlbl_table.lock); |
| 390 | } |
| 391 | |
| 392 | static struct pernet_operations ipv6_addr_label_ops = { |
| 393 | .init = ip6addrlbl_net_init, |
| 394 | .exit = ip6addrlbl_net_exit, |
| 395 | }; |
| 396 | |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 397 | int __init ipv6_addr_label_init(void) |
| 398 | { |
| 399 | spin_lock_init(&ip6addrlbl_table.lock); |
| 400 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 401 | return register_pernet_subsys(&ipv6_addr_label_ops); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 402 | } |
| 403 | |
Neil Horman | 2cc6d2b | 2010-09-24 09:55:52 +0000 | [diff] [blame] | 404 | void ipv6_addr_label_cleanup(void) |
| 405 | { |
| 406 | unregister_pernet_subsys(&ipv6_addr_label_ops); |
| 407 | } |
| 408 | |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 409 | static const struct nla_policy ifal_policy[IFAL_MAX+1] = { |
| 410 | [IFAL_ADDRESS] = { .len = sizeof(struct in6_addr), }, |
| 411 | [IFAL_LABEL] = { .len = sizeof(u32), }, |
| 412 | }; |
| 413 | |
Thomas Graf | 661d296 | 2013-03-21 07:45:29 +0000 | [diff] [blame] | 414 | static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 415 | { |
YOSHIFUJI Hideaki | 3b1e0a6 | 2008-03-26 02:26:21 +0900 | [diff] [blame] | 416 | struct net *net = sock_net(skb->sk); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 417 | struct ifaddrlblmsg *ifal; |
| 418 | struct nlattr *tb[IFAL_MAX+1]; |
| 419 | struct in6_addr *pfx; |
| 420 | u32 label; |
| 421 | int err = 0; |
| 422 | |
| 423 | err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy); |
| 424 | if (err < 0) |
| 425 | return err; |
| 426 | |
| 427 | ifal = nlmsg_data(nlh); |
| 428 | |
| 429 | if (ifal->ifal_family != AF_INET6 || |
| 430 | ifal->ifal_prefixlen > 128) |
| 431 | return -EINVAL; |
| 432 | |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 433 | if (!tb[IFAL_ADDRESS]) |
| 434 | return -EINVAL; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 435 | pfx = nla_data(tb[IFAL_ADDRESS]); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 436 | |
| 437 | if (!tb[IFAL_LABEL]) |
| 438 | return -EINVAL; |
| 439 | label = nla_get_u32(tb[IFAL_LABEL]); |
| 440 | if (label == IPV6_ADDR_LABEL_DEFAULT) |
| 441 | return -EINVAL; |
| 442 | |
Wang Yufen | 1c8669e | 2014-02-17 16:53:34 +0800 | [diff] [blame] | 443 | switch (nlh->nlmsg_type) { |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 444 | case RTM_NEWADDRLABEL: |
Florian Westphal | 0771275 | 2010-05-07 11:31:33 +0000 | [diff] [blame] | 445 | if (ifal->ifal_index && |
| 446 | !__dev_get_by_index(net, ifal->ifal_index)) |
| 447 | return -EINVAL; |
| 448 | |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 449 | err = ip6addrlbl_add(net, pfx, ifal->ifal_prefixlen, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 450 | ifal->ifal_index, label, |
| 451 | nlh->nlmsg_flags & NLM_F_REPLACE); |
| 452 | break; |
| 453 | case RTM_DELADDRLABEL: |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 454 | err = ip6addrlbl_del(net, pfx, ifal->ifal_prefixlen, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 455 | ifal->ifal_index); |
| 456 | break; |
| 457 | default: |
| 458 | err = -EOPNOTSUPP; |
| 459 | } |
| 460 | return err; |
| 461 | } |
| 462 | |
Eric Dumazet | a50feda | 2012-05-18 18:57:34 +0000 | [diff] [blame] | 463 | static void ip6addrlbl_putmsg(struct nlmsghdr *nlh, |
| 464 | int prefixlen, int ifindex, u32 lseq) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 465 | { |
| 466 | struct ifaddrlblmsg *ifal = nlmsg_data(nlh); |
| 467 | ifal->ifal_family = AF_INET6; |
| 468 | ifal->ifal_prefixlen = prefixlen; |
| 469 | ifal->ifal_flags = 0; |
| 470 | ifal->ifal_index = ifindex; |
| 471 | ifal->ifal_seq = lseq; |
| 472 | }; |
| 473 | |
| 474 | static int ip6addrlbl_fill(struct sk_buff *skb, |
| 475 | struct ip6addrlbl_entry *p, |
| 476 | u32 lseq, |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 477 | u32 portid, u32 seq, int event, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 478 | unsigned int flags) |
| 479 | { |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 480 | struct nlmsghdr *nlh = nlmsg_put(skb, portid, seq, event, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 481 | sizeof(struct ifaddrlblmsg), flags); |
| 482 | if (!nlh) |
| 483 | return -EMSGSIZE; |
| 484 | |
| 485 | ip6addrlbl_putmsg(nlh, p->prefixlen, p->ifindex, lseq); |
| 486 | |
| 487 | if (nla_put(skb, IFAL_ADDRESS, 16, &p->prefix) < 0 || |
| 488 | nla_put_u32(skb, IFAL_LABEL, p->label) < 0) { |
| 489 | nlmsg_cancel(skb, nlh); |
| 490 | return -EMSGSIZE; |
| 491 | } |
| 492 | |
Johannes Berg | 053c095 | 2015-01-16 22:09:00 +0100 | [diff] [blame] | 493 | nlmsg_end(skb, nlh); |
| 494 | return 0; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | static int ip6addrlbl_dump(struct sk_buff *skb, struct netlink_callback *cb) |
| 498 | { |
YOSHIFUJI Hideaki | 3b1e0a6 | 2008-03-26 02:26:21 +0900 | [diff] [blame] | 499 | struct net *net = sock_net(skb->sk); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 500 | struct ip6addrlbl_entry *p; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 501 | int idx = 0, s_idx = cb->args[0]; |
| 502 | int err; |
| 503 | |
| 504 | rcu_read_lock(); |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 505 | hlist_for_each_entry_rcu(p, &ip6addrlbl_table.head, list) { |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 506 | if (idx >= s_idx && |
| 507 | net_eq(ip6addrlbl_net(p), net)) { |
Wang Yufen | cb6e926 | 2014-02-17 16:53:35 +0800 | [diff] [blame] | 508 | err = ip6addrlbl_fill(skb, p, |
| 509 | ip6addrlbl_table.seq, |
| 510 | NETLINK_CB(cb->skb).portid, |
| 511 | cb->nlh->nlmsg_seq, |
| 512 | RTM_NEWADDRLABEL, |
| 513 | NLM_F_MULTI); |
Johannes Berg | 053c095 | 2015-01-16 22:09:00 +0100 | [diff] [blame] | 514 | if (err < 0) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 515 | break; |
| 516 | } |
| 517 | idx++; |
| 518 | } |
| 519 | rcu_read_unlock(); |
| 520 | cb->args[0] = idx; |
| 521 | return skb->len; |
| 522 | } |
| 523 | |
| 524 | static inline int ip6addrlbl_msgsize(void) |
| 525 | { |
Eric Dumazet | a02cec2 | 2010-09-22 20:43:57 +0000 | [diff] [blame] | 526 | return NLMSG_ALIGN(sizeof(struct ifaddrlblmsg)) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 527 | + nla_total_size(16) /* IFAL_ADDRESS */ |
Eric Dumazet | a02cec2 | 2010-09-22 20:43:57 +0000 | [diff] [blame] | 528 | + nla_total_size(4); /* IFAL_LABEL */ |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 529 | } |
| 530 | |
Wang Yufen | 22b285d | 2014-02-17 16:53:33 +0800 | [diff] [blame] | 531 | static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 532 | { |
YOSHIFUJI Hideaki | 3b1e0a6 | 2008-03-26 02:26:21 +0900 | [diff] [blame] | 533 | struct net *net = sock_net(in_skb->sk); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 534 | struct ifaddrlblmsg *ifal; |
| 535 | struct nlattr *tb[IFAL_MAX+1]; |
| 536 | struct in6_addr *addr; |
| 537 | u32 lseq; |
| 538 | int err = 0; |
| 539 | struct ip6addrlbl_entry *p; |
| 540 | struct sk_buff *skb; |
| 541 | |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 542 | err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy); |
| 543 | if (err < 0) |
| 544 | return err; |
| 545 | |
| 546 | ifal = nlmsg_data(nlh); |
| 547 | |
| 548 | if (ifal->ifal_family != AF_INET6 || |
| 549 | ifal->ifal_prefixlen != 128) |
| 550 | return -EINVAL; |
| 551 | |
| 552 | if (ifal->ifal_index && |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 553 | !__dev_get_by_index(net, ifal->ifal_index)) |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 554 | return -EINVAL; |
| 555 | |
| 556 | if (!tb[IFAL_ADDRESS]) |
| 557 | return -EINVAL; |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 558 | addr = nla_data(tb[IFAL_ADDRESS]); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 559 | |
| 560 | rcu_read_lock(); |
Benjamin Thery | 3de2325 | 2008-05-28 14:51:24 +0200 | [diff] [blame] | 561 | p = __ipv6_addr_label(net, addr, ipv6_addr_type(addr), ifal->ifal_index); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 562 | if (p && ip6addrlbl_hold(p)) |
| 563 | p = NULL; |
| 564 | lseq = ip6addrlbl_table.seq; |
| 565 | rcu_read_unlock(); |
| 566 | |
| 567 | if (!p) { |
| 568 | err = -ESRCH; |
| 569 | goto out; |
| 570 | } |
| 571 | |
Wang Yufen | cb6e926 | 2014-02-17 16:53:35 +0800 | [diff] [blame] | 572 | skb = nlmsg_new(ip6addrlbl_msgsize(), GFP_KERNEL); |
| 573 | if (!skb) { |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 574 | ip6addrlbl_put(p); |
| 575 | return -ENOBUFS; |
| 576 | } |
| 577 | |
| 578 | err = ip6addrlbl_fill(skb, p, lseq, |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 579 | NETLINK_CB(in_skb).portid, nlh->nlmsg_seq, |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 580 | RTM_NEWADDRLABEL, 0); |
| 581 | |
| 582 | ip6addrlbl_put(p); |
| 583 | |
| 584 | if (err < 0) { |
| 585 | WARN_ON(err == -EMSGSIZE); |
| 586 | kfree_skb(skb); |
| 587 | goto out; |
| 588 | } |
| 589 | |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 590 | err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 591 | out: |
| 592 | return err; |
| 593 | } |
| 594 | |
| 595 | void __init ipv6_addr_label_rtnl_register(void) |
| 596 | { |
Greg Rose | c7ac867 | 2011-06-10 01:27:09 +0000 | [diff] [blame] | 597 | __rtnl_register(PF_INET6, RTM_NEWADDRLABEL, ip6addrlbl_newdel, |
| 598 | NULL, NULL); |
| 599 | __rtnl_register(PF_INET6, RTM_DELADDRLABEL, ip6addrlbl_newdel, |
| 600 | NULL, NULL); |
| 601 | __rtnl_register(PF_INET6, RTM_GETADDRLABEL, ip6addrlbl_get, |
| 602 | ip6addrlbl_dump, NULL); |
YOSHIFUJI Hideaki | 2a8cc6c | 2007-11-14 15:56:23 +0900 | [diff] [blame] | 603 | } |
| 604 | |