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