diff options
author | Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> | 2007-02-09 10:30:33 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:23:41 -0400 |
commit | 3144581cb0b4b1ef897470195128cc1c8dc037b6 (patch) | |
tree | 1d4dd794bcda78fdae4129348c8966c53f3818ad /net/ipv6/ip6_tunnel.c | |
parent | c4d3efafcc933fd2ffd169d7dc4f980393a13796 (diff) |
[IPV6] IP6TUNNEL: Rename functions ip6ip6_* to ip6_tnl_*.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_tunnel.c')
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index a6541495deab..70684e0d31f1 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -74,12 +74,12 @@ MODULE_LICENSE("GPL"); | |||
74 | (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ | 74 | (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ |
75 | (HASH_SIZE - 1)) | 75 | (HASH_SIZE - 1)) |
76 | 76 | ||
77 | static int ip6ip6_fb_tnl_dev_init(struct net_device *dev); | 77 | static int ip6_fb_tnl_dev_init(struct net_device *dev); |
78 | static int ip6ip6_tnl_dev_init(struct net_device *dev); | 78 | static int ip6_tnl_dev_init(struct net_device *dev); |
79 | static void ip6ip6_tnl_dev_setup(struct net_device *dev); | 79 | static void ip6_tnl_dev_setup(struct net_device *dev); |
80 | 80 | ||
81 | /* the IPv6 tunnel fallback device */ | 81 | /* the IPv6 tunnel fallback device */ |
82 | static struct net_device *ip6ip6_fb_tnl_dev; | 82 | static struct net_device *ip6_fb_tnl_dev; |
83 | 83 | ||
84 | 84 | ||
85 | /* lists for storing tunnels in use */ | 85 | /* lists for storing tunnels in use */ |
@@ -88,7 +88,7 @@ static struct ip6_tnl *tnls_wc[1]; | |||
88 | static struct ip6_tnl **tnls[2] = { tnls_wc, tnls_r_l }; | 88 | static struct ip6_tnl **tnls[2] = { tnls_wc, tnls_r_l }; |
89 | 89 | ||
90 | /* lock for the tunnel lists */ | 90 | /* lock for the tunnel lists */ |
91 | static DEFINE_RWLOCK(ip6ip6_lock); | 91 | static DEFINE_RWLOCK(ip6_tnl_lock); |
92 | 92 | ||
93 | static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t) | 93 | static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t) |
94 | { | 94 | { |
@@ -119,7 +119,7 @@ static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst) | |||
119 | } | 119 | } |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses | 122 | * ip6_tnl_lookup - fetch tunnel matching the end-point addresses |
123 | * @remote: the address of the tunnel exit-point | 123 | * @remote: the address of the tunnel exit-point |
124 | * @local: the address of the tunnel entry-point | 124 | * @local: the address of the tunnel entry-point |
125 | * | 125 | * |
@@ -130,7 +130,7 @@ static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst) | |||
130 | **/ | 130 | **/ |
131 | 131 | ||
132 | static struct ip6_tnl * | 132 | static struct ip6_tnl * |
133 | ip6ip6_tnl_lookup(struct in6_addr *remote, struct in6_addr *local) | 133 | ip6_tnl_lookup(struct in6_addr *remote, struct in6_addr *local) |
134 | { | 134 | { |
135 | unsigned h0 = HASH(remote); | 135 | unsigned h0 = HASH(remote); |
136 | unsigned h1 = HASH(local); | 136 | unsigned h1 = HASH(local); |
@@ -149,18 +149,18 @@ ip6ip6_tnl_lookup(struct in6_addr *remote, struct in6_addr *local) | |||
149 | } | 149 | } |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * ip6ip6_bucket - get head of list matching given tunnel parameters | 152 | * ip6_tnl_bucket - get head of list matching given tunnel parameters |
153 | * @p: parameters containing tunnel end-points | 153 | * @p: parameters containing tunnel end-points |
154 | * | 154 | * |
155 | * Description: | 155 | * Description: |
156 | * ip6ip6_bucket() returns the head of the list matching the | 156 | * ip6_tnl_bucket() returns the head of the list matching the |
157 | * &struct in6_addr entries laddr and raddr in @p. | 157 | * &struct in6_addr entries laddr and raddr in @p. |
158 | * | 158 | * |
159 | * Return: head of IPv6 tunnel list | 159 | * Return: head of IPv6 tunnel list |
160 | **/ | 160 | **/ |
161 | 161 | ||
162 | static struct ip6_tnl ** | 162 | static struct ip6_tnl ** |
163 | ip6ip6_bucket(struct ip6_tnl_parm *p) | 163 | ip6_tnl_bucket(struct ip6_tnl_parm *p) |
164 | { | 164 | { |
165 | struct in6_addr *remote = &p->raddr; | 165 | struct in6_addr *remote = &p->raddr; |
166 | struct in6_addr *local = &p->laddr; | 166 | struct in6_addr *local = &p->laddr; |
@@ -175,36 +175,36 @@ ip6ip6_bucket(struct ip6_tnl_parm *p) | |||
175 | } | 175 | } |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * ip6ip6_tnl_link - add tunnel to hash table | 178 | * ip6_tnl_link - add tunnel to hash table |
179 | * @t: tunnel to be added | 179 | * @t: tunnel to be added |
180 | **/ | 180 | **/ |
181 | 181 | ||
182 | static void | 182 | static void |
183 | ip6ip6_tnl_link(struct ip6_tnl *t) | 183 | ip6_tnl_link(struct ip6_tnl *t) |
184 | { | 184 | { |
185 | struct ip6_tnl **tp = ip6ip6_bucket(&t->parms); | 185 | struct ip6_tnl **tp = ip6_tnl_bucket(&t->parms); |
186 | 186 | ||
187 | t->next = *tp; | 187 | t->next = *tp; |
188 | write_lock_bh(&ip6ip6_lock); | 188 | write_lock_bh(&ip6_tnl_lock); |
189 | *tp = t; | 189 | *tp = t; |
190 | write_unlock_bh(&ip6ip6_lock); | 190 | write_unlock_bh(&ip6_tnl_lock); |
191 | } | 191 | } |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * ip6ip6_tnl_unlink - remove tunnel from hash table | 194 | * ip6_tnl_unlink - remove tunnel from hash table |
195 | * @t: tunnel to be removed | 195 | * @t: tunnel to be removed |
196 | **/ | 196 | **/ |
197 | 197 | ||
198 | static void | 198 | static void |
199 | ip6ip6_tnl_unlink(struct ip6_tnl *t) | 199 | ip6_tnl_unlink(struct ip6_tnl *t) |
200 | { | 200 | { |
201 | struct ip6_tnl **tp; | 201 | struct ip6_tnl **tp; |
202 | 202 | ||
203 | for (tp = ip6ip6_bucket(&t->parms); *tp; tp = &(*tp)->next) { | 203 | for (tp = ip6_tnl_bucket(&t->parms); *tp; tp = &(*tp)->next) { |
204 | if (t == *tp) { | 204 | if (t == *tp) { |
205 | write_lock_bh(&ip6ip6_lock); | 205 | write_lock_bh(&ip6_tnl_lock); |
206 | *tp = t->next; | 206 | *tp = t->next; |
207 | write_unlock_bh(&ip6ip6_lock); | 207 | write_unlock_bh(&ip6_tnl_lock); |
208 | break; | 208 | break; |
209 | } | 209 | } |
210 | } | 210 | } |
@@ -241,12 +241,12 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p) | |||
241 | if (i == IP6_TNL_MAX) | 241 | if (i == IP6_TNL_MAX) |
242 | goto failed; | 242 | goto failed; |
243 | } | 243 | } |
244 | dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup); | 244 | dev = alloc_netdev(sizeof (*t), name, ip6_tnl_dev_setup); |
245 | if (dev == NULL) | 245 | if (dev == NULL) |
246 | goto failed; | 246 | goto failed; |
247 | 247 | ||
248 | t = netdev_priv(dev); | 248 | t = netdev_priv(dev); |
249 | dev->init = ip6ip6_tnl_dev_init; | 249 | dev->init = ip6_tnl_dev_init; |
250 | t->parms = *p; | 250 | t->parms = *p; |
251 | 251 | ||
252 | if ((err = register_netdevice(dev)) < 0) { | 252 | if ((err = register_netdevice(dev)) < 0) { |
@@ -254,19 +254,19 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p) | |||
254 | goto failed; | 254 | goto failed; |
255 | } | 255 | } |
256 | dev_hold(dev); | 256 | dev_hold(dev); |
257 | ip6ip6_tnl_link(t); | 257 | ip6_tnl_link(t); |
258 | return t; | 258 | return t; |
259 | failed: | 259 | failed: |
260 | return NULL; | 260 | return NULL; |
261 | } | 261 | } |
262 | 262 | ||
263 | /** | 263 | /** |
264 | * ip6ip6_tnl_locate - find or create tunnel matching given parameters | 264 | * ip6_tnl_locate - find or create tunnel matching given parameters |
265 | * @p: tunnel parameters | 265 | * @p: tunnel parameters |
266 | * @create: != 0 if allowed to create new tunnel if no match found | 266 | * @create: != 0 if allowed to create new tunnel if no match found |
267 | * | 267 | * |
268 | * Description: | 268 | * Description: |
269 | * ip6ip6_tnl_locate() first tries to locate an existing tunnel | 269 | * ip6_tnl_locate() first tries to locate an existing tunnel |
270 | * based on @parms. If this is unsuccessful, but @create is set a new | 270 | * based on @parms. If this is unsuccessful, but @create is set a new |
271 | * tunnel device is created and registered for use. | 271 | * tunnel device is created and registered for use. |
272 | * | 272 | * |
@@ -274,13 +274,13 @@ failed: | |||
274 | * matching tunnel or NULL | 274 | * matching tunnel or NULL |
275 | **/ | 275 | **/ |
276 | 276 | ||
277 | static struct ip6_tnl *ip6ip6_tnl_locate(struct ip6_tnl_parm *p, int create) | 277 | static struct ip6_tnl *ip6_tnl_locate(struct ip6_tnl_parm *p, int create) |
278 | { | 278 | { |
279 | struct in6_addr *remote = &p->raddr; | 279 | struct in6_addr *remote = &p->raddr; |
280 | struct in6_addr *local = &p->laddr; | 280 | struct in6_addr *local = &p->laddr; |
281 | struct ip6_tnl *t; | 281 | struct ip6_tnl *t; |
282 | 282 | ||
283 | for (t = *ip6ip6_bucket(p); t; t = t->next) { | 283 | for (t = *ip6_tnl_bucket(p); t; t = t->next) { |
284 | if (ipv6_addr_equal(local, &t->parms.laddr) && | 284 | if (ipv6_addr_equal(local, &t->parms.laddr) && |
285 | ipv6_addr_equal(remote, &t->parms.raddr)) | 285 | ipv6_addr_equal(remote, &t->parms.raddr)) |
286 | return t; | 286 | return t; |
@@ -291,24 +291,24 @@ static struct ip6_tnl *ip6ip6_tnl_locate(struct ip6_tnl_parm *p, int create) | |||
291 | } | 291 | } |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * ip6ip6_tnl_dev_uninit - tunnel device uninitializer | 294 | * ip6_tnl_dev_uninit - tunnel device uninitializer |
295 | * @dev: the device to be destroyed | 295 | * @dev: the device to be destroyed |
296 | * | 296 | * |
297 | * Description: | 297 | * Description: |
298 | * ip6ip6_tnl_dev_uninit() removes tunnel from its list | 298 | * ip6_tnl_dev_uninit() removes tunnel from its list |
299 | **/ | 299 | **/ |
300 | 300 | ||
301 | static void | 301 | static void |
302 | ip6ip6_tnl_dev_uninit(struct net_device *dev) | 302 | ip6_tnl_dev_uninit(struct net_device *dev) |
303 | { | 303 | { |
304 | struct ip6_tnl *t = netdev_priv(dev); | 304 | struct ip6_tnl *t = netdev_priv(dev); |
305 | 305 | ||
306 | if (dev == ip6ip6_fb_tnl_dev) { | 306 | if (dev == ip6_fb_tnl_dev) { |
307 | write_lock_bh(&ip6ip6_lock); | 307 | write_lock_bh(&ip6_tnl_lock); |
308 | tnls_wc[0] = NULL; | 308 | tnls_wc[0] = NULL; |
309 | write_unlock_bh(&ip6ip6_lock); | 309 | write_unlock_bh(&ip6_tnl_lock); |
310 | } else { | 310 | } else { |
311 | ip6ip6_tnl_unlink(t); | 311 | ip6_tnl_unlink(t); |
312 | } | 312 | } |
313 | ip6_tnl_dst_reset(t); | 313 | ip6_tnl_dst_reset(t); |
314 | dev_put(dev); | 314 | dev_put(dev); |
@@ -400,8 +400,8 @@ ip6_tnl_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
400 | in trouble since we might need the source address for further | 400 | in trouble since we might need the source address for further |
401 | processing of the error. */ | 401 | processing of the error. */ |
402 | 402 | ||
403 | read_lock(&ip6ip6_lock); | 403 | read_lock(&ip6_tnl_lock); |
404 | if ((t = ip6ip6_tnl_lookup(&ipv6h->daddr, &ipv6h->saddr)) == NULL) | 404 | if ((t = ip6_tnl_lookup(&ipv6h->daddr, &ipv6h->saddr)) == NULL) |
405 | goto out; | 405 | goto out; |
406 | 406 | ||
407 | err = 0; | 407 | err = 0; |
@@ -469,7 +469,7 @@ ip6_tnl_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
469 | *msg = rel_msg; | 469 | *msg = rel_msg; |
470 | 470 | ||
471 | out: | 471 | out: |
472 | read_unlock(&ip6ip6_lock); | 472 | read_unlock(&ip6_tnl_lock); |
473 | return err; | 473 | return err; |
474 | } | 474 | } |
475 | 475 | ||
@@ -662,7 +662,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t) | |||
662 | } | 662 | } |
663 | 663 | ||
664 | /** | 664 | /** |
665 | * ip6ip6_rcv - decapsulate IPv6 packet and retransmit it locally | 665 | * ip6_tnl_rcv - decapsulate IPv6 packet and retransmit it locally |
666 | * @skb: received socket buffer | 666 | * @skb: received socket buffer |
667 | * @protocol: ethernet protocol ID | 667 | * @protocol: ethernet protocol ID |
668 | * @dscp_ecn_decapsulate: the function to decapsulate DSCP code and ECN | 668 | * @dscp_ecn_decapsulate: the function to decapsulate DSCP code and ECN |
@@ -680,17 +680,17 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, | |||
680 | 680 | ||
681 | ipv6h = skb->nh.ipv6h; | 681 | ipv6h = skb->nh.ipv6h; |
682 | 682 | ||
683 | read_lock(&ip6ip6_lock); | 683 | read_lock(&ip6_tnl_lock); |
684 | 684 | ||
685 | if ((t = ip6ip6_tnl_lookup(&ipv6h->saddr, &ipv6h->daddr)) != NULL) { | 685 | if ((t = ip6_tnl_lookup(&ipv6h->saddr, &ipv6h->daddr)) != NULL) { |
686 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { | 686 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { |
687 | read_unlock(&ip6ip6_lock); | 687 | read_unlock(&ip6_tnl_lock); |
688 | goto discard; | 688 | goto discard; |
689 | } | 689 | } |
690 | 690 | ||
691 | if (!ip6_tnl_rcv_ctl(t)) { | 691 | if (!ip6_tnl_rcv_ctl(t)) { |
692 | t->stat.rx_dropped++; | 692 | t->stat.rx_dropped++; |
693 | read_unlock(&ip6ip6_lock); | 693 | read_unlock(&ip6_tnl_lock); |
694 | goto discard; | 694 | goto discard; |
695 | } | 695 | } |
696 | secpath_reset(skb); | 696 | secpath_reset(skb); |
@@ -709,10 +709,10 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, | |||
709 | t->stat.rx_packets++; | 709 | t->stat.rx_packets++; |
710 | t->stat.rx_bytes += skb->len; | 710 | t->stat.rx_bytes += skb->len; |
711 | netif_rx(skb); | 711 | netif_rx(skb); |
712 | read_unlock(&ip6ip6_lock); | 712 | read_unlock(&ip6_tnl_lock); |
713 | return 0; | 713 | return 0; |
714 | } | 714 | } |
715 | read_unlock(&ip6ip6_lock); | 715 | read_unlock(&ip6_tnl_lock); |
716 | return 1; | 716 | return 1; |
717 | 717 | ||
718 | discard: | 718 | discard: |
@@ -750,7 +750,7 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit) | |||
750 | } | 750 | } |
751 | 751 | ||
752 | /** | 752 | /** |
753 | * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own | 753 | * ip6_tnl_addr_conflict - compare packet addresses to tunnel's own |
754 | * @t: the outgoing tunnel device | 754 | * @t: the outgoing tunnel device |
755 | * @hdr: IPv6 header from the incoming packet | 755 | * @hdr: IPv6 header from the incoming packet |
756 | * | 756 | * |
@@ -764,7 +764,7 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit) | |||
764 | **/ | 764 | **/ |
765 | 765 | ||
766 | static inline int | 766 | static inline int |
767 | ip6ip6_tnl_addr_conflict(struct ip6_tnl *t, struct ipv6hdr *hdr) | 767 | ip6_tnl_addr_conflict(struct ip6_tnl *t, struct ipv6hdr *hdr) |
768 | { | 768 | { |
769 | return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr); | 769 | return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr); |
770 | } | 770 | } |
@@ -978,7 +978,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
978 | __u32 mtu; | 978 | __u32 mtu; |
979 | int err; | 979 | int err; |
980 | 980 | ||
981 | if (!ip6_tnl_xmit_ctl(t) || ip6ip6_tnl_addr_conflict(t, ipv6h)) | 981 | if (!ip6_tnl_xmit_ctl(t) || ip6_tnl_addr_conflict(t, ipv6h)) |
982 | return -1; | 982 | return -1; |
983 | 983 | ||
984 | if ((offset = parse_tlv_tnl_enc_lim(skb, skb->nh.raw)) > 0) { | 984 | if ((offset = parse_tlv_tnl_enc_lim(skb, skb->nh.raw)) > 0) { |
@@ -1068,7 +1068,7 @@ static void ip6_tnl_set_cap(struct ip6_tnl *t) | |||
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | static void ip6ip6_tnl_link_config(struct ip6_tnl *t) | 1071 | static void ip6_tnl_link_config(struct ip6_tnl *t) |
1072 | { | 1072 | { |
1073 | struct net_device *dev = t->dev; | 1073 | struct net_device *dev = t->dev; |
1074 | struct ip6_tnl_parm *p = &t->parms; | 1074 | struct ip6_tnl_parm *p = &t->parms; |
@@ -1121,17 +1121,17 @@ static void ip6ip6_tnl_link_config(struct ip6_tnl *t) | |||
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | /** | 1123 | /** |
1124 | * ip6ip6_tnl_change - update the tunnel parameters | 1124 | * ip6_tnl_change - update the tunnel parameters |
1125 | * @t: tunnel to be changed | 1125 | * @t: tunnel to be changed |
1126 | * @p: tunnel configuration parameters | 1126 | * @p: tunnel configuration parameters |
1127 | * @active: != 0 if tunnel is ready for use | 1127 | * @active: != 0 if tunnel is ready for use |
1128 | * | 1128 | * |
1129 | * Description: | 1129 | * Description: |
1130 | * ip6ip6_tnl_change() updates the tunnel parameters | 1130 | * ip6_tnl_change() updates the tunnel parameters |
1131 | **/ | 1131 | **/ |
1132 | 1132 | ||
1133 | static int | 1133 | static int |
1134 | ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p) | 1134 | ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p) |
1135 | { | 1135 | { |
1136 | ipv6_addr_copy(&t->parms.laddr, &p->laddr); | 1136 | ipv6_addr_copy(&t->parms.laddr, &p->laddr); |
1137 | ipv6_addr_copy(&t->parms.raddr, &p->raddr); | 1137 | ipv6_addr_copy(&t->parms.raddr, &p->raddr); |
@@ -1141,18 +1141,18 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p) | |||
1141 | t->parms.flowinfo = p->flowinfo; | 1141 | t->parms.flowinfo = p->flowinfo; |
1142 | t->parms.link = p->link; | 1142 | t->parms.link = p->link; |
1143 | ip6_tnl_dst_reset(t); | 1143 | ip6_tnl_dst_reset(t); |
1144 | ip6ip6_tnl_link_config(t); | 1144 | ip6_tnl_link_config(t); |
1145 | return 0; | 1145 | return 0; |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | /** | 1148 | /** |
1149 | * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace | 1149 | * ip6_tnl_ioctl - configure ipv6 tunnels from userspace |
1150 | * @dev: virtual device associated with tunnel | 1150 | * @dev: virtual device associated with tunnel |
1151 | * @ifr: parameters passed from userspace | 1151 | * @ifr: parameters passed from userspace |
1152 | * @cmd: command to be performed | 1152 | * @cmd: command to be performed |
1153 | * | 1153 | * |
1154 | * Description: | 1154 | * Description: |
1155 | * ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels | 1155 | * ip6_tnl_ioctl() is used for managing IPv6 tunnels |
1156 | * from userspace. | 1156 | * from userspace. |
1157 | * | 1157 | * |
1158 | * The possible commands are the following: | 1158 | * The possible commands are the following: |
@@ -1174,7 +1174,7 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p) | |||
1174 | **/ | 1174 | **/ |
1175 | 1175 | ||
1176 | static int | 1176 | static int |
1177 | ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 1177 | ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
1178 | { | 1178 | { |
1179 | int err = 0; | 1179 | int err = 0; |
1180 | struct ip6_tnl_parm p; | 1180 | struct ip6_tnl_parm p; |
@@ -1182,12 +1182,12 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1182 | 1182 | ||
1183 | switch (cmd) { | 1183 | switch (cmd) { |
1184 | case SIOCGETTUNNEL: | 1184 | case SIOCGETTUNNEL: |
1185 | if (dev == ip6ip6_fb_tnl_dev) { | 1185 | if (dev == ip6_fb_tnl_dev) { |
1186 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p))) { | 1186 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p))) { |
1187 | err = -EFAULT; | 1187 | err = -EFAULT; |
1188 | break; | 1188 | break; |
1189 | } | 1189 | } |
1190 | t = ip6ip6_tnl_locate(&p, 0); | 1190 | t = ip6_tnl_locate(&p, 0); |
1191 | } | 1191 | } |
1192 | if (t == NULL) | 1192 | if (t == NULL) |
1193 | t = netdev_priv(dev); | 1193 | t = netdev_priv(dev); |
@@ -1207,8 +1207,8 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1207 | err = -EINVAL; | 1207 | err = -EINVAL; |
1208 | if (p.proto != IPPROTO_IPV6) | 1208 | if (p.proto != IPPROTO_IPV6) |
1209 | break; | 1209 | break; |
1210 | t = ip6ip6_tnl_locate(&p, cmd == SIOCADDTUNNEL); | 1210 | t = ip6_tnl_locate(&p, cmd == SIOCADDTUNNEL); |
1211 | if (dev != ip6ip6_fb_tnl_dev && cmd == SIOCCHGTUNNEL) { | 1211 | if (dev != ip6_fb_tnl_dev && cmd == SIOCCHGTUNNEL) { |
1212 | if (t != NULL) { | 1212 | if (t != NULL) { |
1213 | if (t->dev != dev) { | 1213 | if (t->dev != dev) { |
1214 | err = -EEXIST; | 1214 | err = -EEXIST; |
@@ -1217,9 +1217,9 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1217 | } else | 1217 | } else |
1218 | t = netdev_priv(dev); | 1218 | t = netdev_priv(dev); |
1219 | 1219 | ||
1220 | ip6ip6_tnl_unlink(t); | 1220 | ip6_tnl_unlink(t); |
1221 | err = ip6ip6_tnl_change(t, &p); | 1221 | err = ip6_tnl_change(t, &p); |
1222 | ip6ip6_tnl_link(t); | 1222 | ip6_tnl_link(t); |
1223 | netdev_state_change(dev); | 1223 | netdev_state_change(dev); |
1224 | } | 1224 | } |
1225 | if (t) { | 1225 | if (t) { |
@@ -1235,15 +1235,15 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1235 | if (!capable(CAP_NET_ADMIN)) | 1235 | if (!capable(CAP_NET_ADMIN)) |
1236 | break; | 1236 | break; |
1237 | 1237 | ||
1238 | if (dev == ip6ip6_fb_tnl_dev) { | 1238 | if (dev == ip6_fb_tnl_dev) { |
1239 | err = -EFAULT; | 1239 | err = -EFAULT; |
1240 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p))) | 1240 | if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p))) |
1241 | break; | 1241 | break; |
1242 | err = -ENOENT; | 1242 | err = -ENOENT; |
1243 | if ((t = ip6ip6_tnl_locate(&p, 0)) == NULL) | 1243 | if ((t = ip6_tnl_locate(&p, 0)) == NULL) |
1244 | break; | 1244 | break; |
1245 | err = -EPERM; | 1245 | err = -EPERM; |
1246 | if (t->dev == ip6ip6_fb_tnl_dev) | 1246 | if (t->dev == ip6_fb_tnl_dev) |
1247 | break; | 1247 | break; |
1248 | dev = t->dev; | 1248 | dev = t->dev; |
1249 | } | 1249 | } |
@@ -1257,20 +1257,20 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | /** | 1259 | /** |
1260 | * ip6ip6_tnl_get_stats - return the stats for tunnel device | 1260 | * ip6_tnl_get_stats - return the stats for tunnel device |
1261 | * @dev: virtual device associated with tunnel | 1261 | * @dev: virtual device associated with tunnel |
1262 | * | 1262 | * |
1263 | * Return: stats for device | 1263 | * Return: stats for device |
1264 | **/ | 1264 | **/ |
1265 | 1265 | ||
1266 | static struct net_device_stats * | 1266 | static struct net_device_stats * |
1267 | ip6ip6_tnl_get_stats(struct net_device *dev) | 1267 | ip6_tnl_get_stats(struct net_device *dev) |
1268 | { | 1268 | { |
1269 | return &(((struct ip6_tnl *)netdev_priv(dev))->stat); | 1269 | return &(((struct ip6_tnl *)netdev_priv(dev))->stat); |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | /** | 1272 | /** |
1273 | * ip6ip6_tnl_change_mtu - change mtu manually for tunnel device | 1273 | * ip6_tnl_change_mtu - change mtu manually for tunnel device |
1274 | * @dev: virtual device associated with tunnel | 1274 | * @dev: virtual device associated with tunnel |
1275 | * @new_mtu: the new mtu | 1275 | * @new_mtu: the new mtu |
1276 | * | 1276 | * |
@@ -1280,7 +1280,7 @@ ip6ip6_tnl_get_stats(struct net_device *dev) | |||
1280 | **/ | 1280 | **/ |
1281 | 1281 | ||
1282 | static int | 1282 | static int |
1283 | ip6ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) | 1283 | ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) |
1284 | { | 1284 | { |
1285 | if (new_mtu < IPV6_MIN_MTU) { | 1285 | if (new_mtu < IPV6_MIN_MTU) { |
1286 | return -EINVAL; | 1286 | return -EINVAL; |
@@ -1290,22 +1290,22 @@ ip6ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) | |||
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | /** | 1292 | /** |
1293 | * ip6ip6_tnl_dev_setup - setup virtual tunnel device | 1293 | * ip6_tnl_dev_setup - setup virtual tunnel device |
1294 | * @dev: virtual device associated with tunnel | 1294 | * @dev: virtual device associated with tunnel |
1295 | * | 1295 | * |
1296 | * Description: | 1296 | * Description: |
1297 | * Initialize function pointers and device parameters | 1297 | * Initialize function pointers and device parameters |
1298 | **/ | 1298 | **/ |
1299 | 1299 | ||
1300 | static void ip6ip6_tnl_dev_setup(struct net_device *dev) | 1300 | static void ip6_tnl_dev_setup(struct net_device *dev) |
1301 | { | 1301 | { |
1302 | SET_MODULE_OWNER(dev); | 1302 | SET_MODULE_OWNER(dev); |
1303 | dev->uninit = ip6ip6_tnl_dev_uninit; | 1303 | dev->uninit = ip6_tnl_dev_uninit; |
1304 | dev->destructor = free_netdev; | 1304 | dev->destructor = free_netdev; |
1305 | dev->hard_start_xmit = ip6_tnl_xmit; | 1305 | dev->hard_start_xmit = ip6_tnl_xmit; |
1306 | dev->get_stats = ip6ip6_tnl_get_stats; | 1306 | dev->get_stats = ip6_tnl_get_stats; |
1307 | dev->do_ioctl = ip6ip6_tnl_ioctl; | 1307 | dev->do_ioctl = ip6_tnl_ioctl; |
1308 | dev->change_mtu = ip6ip6_tnl_change_mtu; | 1308 | dev->change_mtu = ip6_tnl_change_mtu; |
1309 | 1309 | ||
1310 | dev->type = ARPHRD_TUNNEL6; | 1310 | dev->type = ARPHRD_TUNNEL6; |
1311 | dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr); | 1311 | dev->hard_header_len = LL_MAX_HEADER + sizeof (struct ipv6hdr); |
@@ -1316,12 +1316,12 @@ static void ip6ip6_tnl_dev_setup(struct net_device *dev) | |||
1316 | 1316 | ||
1317 | 1317 | ||
1318 | /** | 1318 | /** |
1319 | * ip6ip6_tnl_dev_init_gen - general initializer for all tunnel devices | 1319 | * ip6_tnl_dev_init_gen - general initializer for all tunnel devices |
1320 | * @dev: virtual device associated with tunnel | 1320 | * @dev: virtual device associated with tunnel |
1321 | **/ | 1321 | **/ |
1322 | 1322 | ||
1323 | static inline void | 1323 | static inline void |
1324 | ip6ip6_tnl_dev_init_gen(struct net_device *dev) | 1324 | ip6_tnl_dev_init_gen(struct net_device *dev) |
1325 | { | 1325 | { |
1326 | struct ip6_tnl *t = netdev_priv(dev); | 1326 | struct ip6_tnl *t = netdev_priv(dev); |
1327 | t->fl.proto = IPPROTO_IPV6; | 1327 | t->fl.proto = IPPROTO_IPV6; |
@@ -1330,31 +1330,31 @@ ip6ip6_tnl_dev_init_gen(struct net_device *dev) | |||
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | /** | 1332 | /** |
1333 | * ip6ip6_tnl_dev_init - initializer for all non fallback tunnel devices | 1333 | * ip6_tnl_dev_init - initializer for all non fallback tunnel devices |
1334 | * @dev: virtual device associated with tunnel | 1334 | * @dev: virtual device associated with tunnel |
1335 | **/ | 1335 | **/ |
1336 | 1336 | ||
1337 | static int | 1337 | static int |
1338 | ip6ip6_tnl_dev_init(struct net_device *dev) | 1338 | ip6_tnl_dev_init(struct net_device *dev) |
1339 | { | 1339 | { |
1340 | struct ip6_tnl *t = netdev_priv(dev); | 1340 | struct ip6_tnl *t = netdev_priv(dev); |
1341 | ip6ip6_tnl_dev_init_gen(dev); | 1341 | ip6_tnl_dev_init_gen(dev); |
1342 | ip6ip6_tnl_link_config(t); | 1342 | ip6_tnl_link_config(t); |
1343 | return 0; | 1343 | return 0; |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | /** | 1346 | /** |
1347 | * ip6ip6_fb_tnl_dev_init - initializer for fallback tunnel device | 1347 | * ip6_fb_tnl_dev_init - initializer for fallback tunnel device |
1348 | * @dev: fallback device | 1348 | * @dev: fallback device |
1349 | * | 1349 | * |
1350 | * Return: 0 | 1350 | * Return: 0 |
1351 | **/ | 1351 | **/ |
1352 | 1352 | ||
1353 | static int | 1353 | static int |
1354 | ip6ip6_fb_tnl_dev_init(struct net_device *dev) | 1354 | ip6_fb_tnl_dev_init(struct net_device *dev) |
1355 | { | 1355 | { |
1356 | struct ip6_tnl *t = netdev_priv(dev); | 1356 | struct ip6_tnl *t = netdev_priv(dev); |
1357 | ip6ip6_tnl_dev_init_gen(dev); | 1357 | ip6_tnl_dev_init_gen(dev); |
1358 | dev_hold(dev); | 1358 | dev_hold(dev); |
1359 | tnls_wc[0] = t; | 1359 | tnls_wc[0] = t; |
1360 | return 0; | 1360 | return 0; |
@@ -1383,27 +1383,27 @@ static int __init ip6_tunnel_init(void) | |||
1383 | int err; | 1383 | int err; |
1384 | 1384 | ||
1385 | if (xfrm6_tunnel_register(&ip4ip6_handler, AF_INET)) { | 1385 | if (xfrm6_tunnel_register(&ip4ip6_handler, AF_INET)) { |
1386 | printk(KERN_ERR "ip4ip6 init: can't register tunnel\n"); | 1386 | printk(KERN_ERR "ip6_tunnel init: can't register ip4ip6\n"); |
1387 | err = -EAGAIN; | 1387 | err = -EAGAIN; |
1388 | goto out; | 1388 | goto out; |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | if (xfrm6_tunnel_register(&ip6ip6_handler, AF_INET6)) { | 1391 | if (xfrm6_tunnel_register(&ip6ip6_handler, AF_INET6)) { |
1392 | printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); | 1392 | printk(KERN_ERR "ip6_tunnel init: can't register ip6ip6\n"); |
1393 | err = -EAGAIN; | 1393 | err = -EAGAIN; |
1394 | goto unreg_ip4ip6; | 1394 | goto unreg_ip4ip6; |
1395 | } | 1395 | } |
1396 | ip6ip6_fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0", | 1396 | ip6_fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0", |
1397 | ip6ip6_tnl_dev_setup); | 1397 | ip6_tnl_dev_setup); |
1398 | 1398 | ||
1399 | if (!ip6ip6_fb_tnl_dev) { | 1399 | if (!ip6_fb_tnl_dev) { |
1400 | err = -ENOMEM; | 1400 | err = -ENOMEM; |
1401 | goto fail; | 1401 | goto fail; |
1402 | } | 1402 | } |
1403 | ip6ip6_fb_tnl_dev->init = ip6ip6_fb_tnl_dev_init; | 1403 | ip6_fb_tnl_dev->init = ip6_fb_tnl_dev_init; |
1404 | 1404 | ||
1405 | if ((err = register_netdev(ip6ip6_fb_tnl_dev))) { | 1405 | if ((err = register_netdev(ip6_fb_tnl_dev))) { |
1406 | free_netdev(ip6ip6_fb_tnl_dev); | 1406 | free_netdev(ip6_fb_tnl_dev); |
1407 | goto fail; | 1407 | goto fail; |
1408 | } | 1408 | } |
1409 | return 0; | 1409 | return 0; |
@@ -1415,7 +1415,7 @@ out: | |||
1415 | return err; | 1415 | return err; |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | static void __exit ip6ip6_destroy_tunnels(void) | 1418 | static void __exit ip6_tnl_destroy_tunnels(void) |
1419 | { | 1419 | { |
1420 | int h; | 1420 | int h; |
1421 | struct ip6_tnl *t; | 1421 | struct ip6_tnl *t; |
@@ -1436,13 +1436,13 @@ static void __exit ip6ip6_destroy_tunnels(void) | |||
1436 | static void __exit ip6_tunnel_cleanup(void) | 1436 | static void __exit ip6_tunnel_cleanup(void) |
1437 | { | 1437 | { |
1438 | if (xfrm6_tunnel_deregister(&ip4ip6_handler, AF_INET)) | 1438 | if (xfrm6_tunnel_deregister(&ip4ip6_handler, AF_INET)) |
1439 | printk(KERN_INFO "ip4ip6 close: can't deregister tunnel\n"); | 1439 | printk(KERN_INFO "ip6_tunnel close: can't deregister ip4ip6\n"); |
1440 | 1440 | ||
1441 | if (xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6)) | 1441 | if (xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6)) |
1442 | printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); | 1442 | printk(KERN_INFO "ip6_tunnel close: can't deregister ip6ip6\n"); |
1443 | 1443 | ||
1444 | rtnl_lock(); | 1444 | rtnl_lock(); |
1445 | ip6ip6_destroy_tunnels(); | 1445 | ip6_tnl_destroy_tunnels(); |
1446 | rtnl_unlock(); | 1446 | rtnl_unlock(); |
1447 | } | 1447 | } |
1448 | 1448 | ||