aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/addrconf.c270
-rw-r--r--net/ipv6/af_inet6.c40
-rw-r--r--net/ipv6/ah6.c40
-rw-r--r--net/ipv6/anycast.c6
-rw-r--r--net/ipv6/datagram.c54
-rw-r--r--net/ipv6/esp6.c30
-rw-r--r--net/ipv6/exthdrs.c14
-rw-r--r--net/ipv6/exthdrs_core.c16
-rw-r--r--net/ipv6/icmp.c38
-rw-r--r--net/ipv6/inet6_hashtables.c102
-rw-r--r--net/ipv6/ip6_fib.c69
-rw-r--r--net/ipv6/ip6_flowlabel.c6
-rw-r--r--net/ipv6/ip6_input.c18
-rw-r--r--net/ipv6/ip6_output.c24
-rw-r--r--net/ipv6/ip6_tunnel.c87
-rw-r--r--net/ipv6/ipcomp6.c22
-rw-r--r--net/ipv6/ipv6_sockglue.c12
-rw-r--r--net/ipv6/mcast.c42
-rw-r--r--net/ipv6/mip6.c28
-rw-r--r--net/ipv6/ndisc.c138
-rw-r--r--net/ipv6/netfilter.c4
-rw-r--r--net/ipv6/netfilter/Kconfig11
-rw-r--r--net/ipv6/netfilter/Makefile1
-rw-r--r--net/ipv6/netfilter/ip6_queue.c152
-rw-r--r--net/ipv6/netfilter/ip6_tables.c52
-rw-r--r--net/ipv6/netfilter/ip6t_HL.c29
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c27
-rw-r--r--net/ipv6/netfilter/ip6t_REJECT.c46
-rw-r--r--net/ipv6/netfilter/ip6t_ah.c30
-rw-r--r--net/ipv6/netfilter/ip6t_eui64.c8
-rw-r--r--net/ipv6/netfilter/ip6t_frag.c8
-rw-r--r--net/ipv6/netfilter/ip6t_hbh.c1
-rw-r--r--net/ipv6/netfilter/ip6t_hl.c13
-rw-r--r--net/ipv6/netfilter/ip6t_ipv6header.c10
-rw-r--r--net/ipv6/netfilter/ip6t_mh.c115
-rw-r--r--net/ipv6/netfilter/ip6t_owner.c8
-rw-r--r--net/ipv6/netfilter/ip6t_rt.c8
-rw-r--r--net/ipv6/netfilter/ip6table_filter.c21
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c31
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c35
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c8
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c7
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c50
-rw-r--r--net/ipv6/proc.c26
-rw-r--r--net/ipv6/protocol.c2
-rw-r--r--net/ipv6/raw.c95
-rw-r--r--net/ipv6/reassembly.c32
-rw-r--r--net/ipv6/route.c143
-rw-r--r--net/ipv6/sit.c13
-rw-r--r--net/ipv6/sysctl_net_ipv6.c4
-rw-r--r--net/ipv6/tcp_ipv6.c100
-rw-r--r--net/ipv6/udp.c66
-rw-r--r--net/ipv6/udp_impl.h6
-rw-r--r--net/ipv6/xfrm6_input.c18
-rw-r--r--net/ipv6/xfrm6_mode_tunnel.c42
-rw-r--r--net/ipv6/xfrm6_output.c8
-rw-r--r--net/ipv6/xfrm6_policy.c54
-rw-r--r--net/ipv6/xfrm6_state.c3
-rw-r--r--net/ipv6/xfrm6_tunnel.c22
59 files changed, 1258 insertions, 1107 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index e3854696988d..ea0755b09033 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3,7 +3,7 @@
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
8 * 8 *
9 * $Id: addrconf.c,v 1.69 2001/10/31 21:55:54 davem Exp $ 9 * $Id: addrconf.c,v 1.69 2001/10/31 21:55:54 davem Exp $
@@ -105,7 +105,7 @@ static void addrconf_sysctl_unregister(struct ipv6_devconf *p);
105 105
106#ifdef CONFIG_IPV6_PRIVACY 106#ifdef CONFIG_IPV6_PRIVACY
107static int __ipv6_regen_rndid(struct inet6_dev *idev); 107static int __ipv6_regen_rndid(struct inet6_dev *idev);
108static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); 108static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
109static void ipv6_regen_rndid(unsigned long data); 109static void ipv6_regen_rndid(unsigned long data);
110 110
111static int desync_factor = MAX_DESYNC_FACTOR * HZ; 111static int desync_factor = MAX_DESYNC_FACTOR * HZ;
@@ -137,7 +137,7 @@ static void addrconf_rs_timer(unsigned long data);
137static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa); 137static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
138static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa); 138static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
139 139
140static void inet6_prefix_notify(int event, struct inet6_dev *idev, 140static void inet6_prefix_notify(int event, struct inet6_dev *idev,
141 struct prefix_info *pinfo); 141 struct prefix_info *pinfo);
142static int ipv6_chk_same_addr(const struct in6_addr *addr, struct net_device *dev); 142static int ipv6_chk_same_addr(const struct in6_addr *addr, struct net_device *dev);
143 143
@@ -241,7 +241,7 @@ int __ipv6_addr_type(const struct in6_addr *addr)
241 */ 241 */
242 if ((st & htonl(0xE0000000)) != htonl(0x00000000) && 242 if ((st & htonl(0xE0000000)) != htonl(0x00000000) &&
243 (st & htonl(0xE0000000)) != htonl(0xE0000000)) 243 (st & htonl(0xE0000000)) != htonl(0xE0000000))
244 return (IPV6_ADDR_UNICAST | 244 return (IPV6_ADDR_UNICAST |
245 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); 245 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));
246 246
247 if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) { 247 if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) {
@@ -252,7 +252,7 @@ int __ipv6_addr_type(const struct in6_addr *addr)
252 } 252 }
253 253
254 if ((st & htonl(0xFFC00000)) == htonl(0xFE800000)) 254 if ((st & htonl(0xFFC00000)) == htonl(0xFE800000))
255 return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST | 255 return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST |
256 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.1 */ 256 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.1 */
257 if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000)) 257 if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000))
258 return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST | 258 return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST |
@@ -272,11 +272,11 @@ int __ipv6_addr_type(const struct in6_addr *addr)
272 } 272 }
273 273
274 if (addr->s6_addr32[2] == htonl(0x0000ffff)) 274 if (addr->s6_addr32[2] == htonl(0x0000ffff))
275 return (IPV6_ADDR_MAPPED | 275 return (IPV6_ADDR_MAPPED |
276 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */ 276 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */
277 } 277 }
278 278
279 return (IPV6_ADDR_RESERVED | 279 return (IPV6_ADDR_RESERVED |
280 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.4 */ 280 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.4 */
281} 281}
282 282
@@ -348,10 +348,10 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
348 if (dev->mtu < IPV6_MIN_MTU) 348 if (dev->mtu < IPV6_MIN_MTU)
349 return NULL; 349 return NULL;
350 350
351 ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL); 351 ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
352 352
353 if (ndev == NULL) 353 if (ndev == NULL)
354 return NULL; 354 return NULL;
355 355
356 rwlock_init(&ndev->lock); 356 rwlock_init(&ndev->lock);
357 ndev->dev = dev; 357 ndev->dev = dev;
@@ -462,7 +462,7 @@ static void dev_forward_change(struct inet6_dev *idev)
462 dev = idev->dev; 462 dev = idev->dev;
463 if (dev && (dev->flags & IFF_MULTICAST)) { 463 if (dev && (dev->flags & IFF_MULTICAST)) {
464 ipv6_addr_all_routers(&addr); 464 ipv6_addr_all_routers(&addr);
465 465
466 if (idev->cnf.forwarding) 466 if (idev->cnf.forwarding)
467 ipv6_dev_mc_inc(dev, &addr); 467 ipv6_dev_mc_inc(dev, &addr);
468 else 468 else
@@ -817,8 +817,8 @@ retry:
817 tmp_valid_lft = min_t(__u32, 817 tmp_valid_lft = min_t(__u32,
818 ifp->valid_lft, 818 ifp->valid_lft,
819 idev->cnf.temp_valid_lft); 819 idev->cnf.temp_valid_lft);
820 tmp_prefered_lft = min_t(__u32, 820 tmp_prefered_lft = min_t(__u32,
821 ifp->prefered_lft, 821 ifp->prefered_lft,
822 idev->cnf.temp_prefered_lft - desync_factor / HZ); 822 idev->cnf.temp_prefered_lft - desync_factor / HZ);
823 tmp_plen = ifp->prefix_len; 823 tmp_plen = ifp->prefix_len;
824 max_addresses = idev->cnf.max_addresses; 824 max_addresses = idev->cnf.max_addresses;
@@ -828,7 +828,7 @@ retry:
828 828
829 write_unlock(&idev->lock); 829 write_unlock(&idev->lock);
830 ift = !max_addresses || 830 ift = !max_addresses ||
831 ipv6_count_addresses(idev) < max_addresses ? 831 ipv6_count_addresses(idev) < max_addresses ?
832 ipv6_add_addr(idev, &addr, tmp_plen, 832 ipv6_add_addr(idev, &addr, tmp_plen,
833 ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK, IFA_F_TEMPORARY) : NULL; 833 ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK, IFA_F_TEMPORARY) : NULL;
834 if (!ift || IS_ERR(ift)) { 834 if (!ift || IS_ERR(ift)) {
@@ -1160,7 +1160,7 @@ record_it:
1160 1160
1161 if (!ifa_result) 1161 if (!ifa_result)
1162 return -EADDRNOTAVAIL; 1162 return -EADDRNOTAVAIL;
1163 1163
1164 ipv6_addr_copy(saddr, &ifa_result->addr); 1164 ipv6_addr_copy(saddr, &ifa_result->addr);
1165 in6_ifa_put(ifa_result); 1165 in6_ifa_put(ifa_result);
1166 return 0; 1166 return 0;
@@ -1475,7 +1475,7 @@ regen:
1475 * - value 0 1475 * - value 0
1476 * - XXX: already assigned to an address on the device 1476 * - XXX: already assigned to an address on the device
1477 */ 1477 */
1478 if (idev->rndid[0] == 0xfd && 1478 if (idev->rndid[0] == 0xfd &&
1479 (idev->rndid[1]&idev->rndid[2]&idev->rndid[3]&idev->rndid[4]&idev->rndid[5]&idev->rndid[6]) == 0xff && 1479 (idev->rndid[1]&idev->rndid[2]&idev->rndid[3]&idev->rndid[4]&idev->rndid[5]&idev->rndid[6]) == 0xff &&
1480 (idev->rndid[7]&0x80)) 1480 (idev->rndid[7]&0x80))
1481 goto regen; 1481 goto regen;
@@ -1502,9 +1502,9 @@ static void ipv6_regen_rndid(unsigned long data)
1502 1502
1503 if (__ipv6_regen_rndid(idev) < 0) 1503 if (__ipv6_regen_rndid(idev) < 0)
1504 goto out; 1504 goto out;
1505 1505
1506 expires = jiffies + 1506 expires = jiffies +
1507 idev->cnf.temp_prefered_lft * HZ - 1507 idev->cnf.temp_prefered_lft * HZ -
1508 idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time - desync_factor; 1508 idev->cnf.regen_max_retry * idev->cnf.dad_transmits * idev->nd_parms->retrans_time - desync_factor;
1509 if (time_before(expires, jiffies)) { 1509 if (time_before(expires, jiffies)) {
1510 printk(KERN_WARNING 1510 printk(KERN_WARNING
@@ -1630,12 +1630,12 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
1630 struct inet6_dev *in6_dev; 1630 struct inet6_dev *in6_dev;
1631 1631
1632 pinfo = (struct prefix_info *) opt; 1632 pinfo = (struct prefix_info *) opt;
1633 1633
1634 if (len < sizeof(struct prefix_info)) { 1634 if (len < sizeof(struct prefix_info)) {
1635 ADBG(("addrconf: prefix option too short\n")); 1635 ADBG(("addrconf: prefix option too short\n"));
1636 return; 1636 return;
1637 } 1637 }
1638 1638
1639 /* 1639 /*
1640 * Validation checks ([ADDRCONF], page 19) 1640 * Validation checks ([ADDRCONF], page 19)
1641 */ 1641 */
@@ -1827,7 +1827,7 @@ ok:
1827 * When a new public address is created as described in [ADDRCONF], 1827 * When a new public address is created as described in [ADDRCONF],
1828 * also create a new temporary address. 1828 * also create a new temporary address.
1829 */ 1829 */
1830 read_unlock_bh(&in6_dev->lock); 1830 read_unlock_bh(&in6_dev->lock);
1831 ipv6_create_tempaddr(ifp, NULL); 1831 ipv6_create_tempaddr(ifp, NULL);
1832 } else { 1832 } else {
1833 read_unlock_bh(&in6_dev->lock); 1833 read_unlock_bh(&in6_dev->lock);
@@ -1913,14 +1913,14 @@ static int inet6_addr_add(int ifindex, struct in6_addr *pfx, int plen,
1913 int scope; 1913 int scope;
1914 1914
1915 ASSERT_RTNL(); 1915 ASSERT_RTNL();
1916 1916
1917 /* check the lifetime */ 1917 /* check the lifetime */
1918 if (!valid_lft || prefered_lft > valid_lft) 1918 if (!valid_lft || prefered_lft > valid_lft)
1919 return -EINVAL; 1919 return -EINVAL;
1920 1920
1921 if ((dev = __dev_get_by_index(ifindex)) == NULL) 1921 if ((dev = __dev_get_by_index(ifindex)) == NULL)
1922 return -ENODEV; 1922 return -ENODEV;
1923 1923
1924 if ((idev = addrconf_add_dev(dev)) == NULL) 1924 if ((idev = addrconf_add_dev(dev)) == NULL)
1925 return -ENOBUFS; 1925 return -ENOBUFS;
1926 1926
@@ -1960,7 +1960,7 @@ static int inet6_addr_del(int ifindex, struct in6_addr *pfx, int plen)
1960 struct inet6_ifaddr *ifp; 1960 struct inet6_ifaddr *ifp;
1961 struct inet6_dev *idev; 1961 struct inet6_dev *idev;
1962 struct net_device *dev; 1962 struct net_device *dev;
1963 1963
1964 if ((dev = __dev_get_by_index(ifindex)) == NULL) 1964 if ((dev = __dev_get_by_index(ifindex)) == NULL)
1965 return -ENODEV; 1965 return -ENODEV;
1966 1966
@@ -1973,7 +1973,7 @@ static int inet6_addr_del(int ifindex, struct in6_addr *pfx, int plen)
1973 ipv6_addr_equal(pfx, &ifp->addr)) { 1973 ipv6_addr_equal(pfx, &ifp->addr)) {
1974 in6_ifa_hold(ifp); 1974 in6_ifa_hold(ifp);
1975 read_unlock_bh(&idev->lock); 1975 read_unlock_bh(&idev->lock);
1976 1976
1977 ipv6_del_addr(ifp); 1977 ipv6_del_addr(ifp);
1978 1978
1979 /* If the last address is deleted administratively, 1979 /* If the last address is deleted administratively,
@@ -1993,10 +1993,10 @@ int addrconf_add_ifaddr(void __user *arg)
1993{ 1993{
1994 struct in6_ifreq ireq; 1994 struct in6_ifreq ireq;
1995 int err; 1995 int err;
1996 1996
1997 if (!capable(CAP_NET_ADMIN)) 1997 if (!capable(CAP_NET_ADMIN))
1998 return -EPERM; 1998 return -EPERM;
1999 1999
2000 if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq))) 2000 if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
2001 return -EFAULT; 2001 return -EFAULT;
2002 2002
@@ -2011,7 +2011,7 @@ int addrconf_del_ifaddr(void __user *arg)
2011{ 2011{
2012 struct in6_ifreq ireq; 2012 struct in6_ifreq ireq;
2013 int err; 2013 int err;
2014 2014
2015 if (!capable(CAP_NET_ADMIN)) 2015 if (!capable(CAP_NET_ADMIN))
2016 return -EPERM; 2016 return -EPERM;
2017 2017
@@ -2056,7 +2056,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2056 return; 2056 return;
2057 } 2057 }
2058 2058
2059 for (dev = dev_base; dev != NULL; dev = dev->next) { 2059 for (dev = dev_base; dev != NULL; dev = dev->next) {
2060 struct in_device * in_dev = __in_dev_get_rtnl(dev); 2060 struct in_device * in_dev = __in_dev_get_rtnl(dev);
2061 if (in_dev && (dev->flags & IFF_UP)) { 2061 if (in_dev && (dev->flags & IFF_UP)) {
2062 struct in_ifaddr * ifa; 2062 struct in_ifaddr * ifa;
@@ -2091,7 +2091,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2091 } 2091 }
2092 } 2092 }
2093 } 2093 }
2094 } 2094 }
2095} 2095}
2096#endif 2096#endif
2097 2097
@@ -2137,7 +2137,7 @@ static void addrconf_dev_config(struct net_device *dev)
2137 2137
2138 ASSERT_RTNL(); 2138 ASSERT_RTNL();
2139 2139
2140 if ((dev->type != ARPHRD_ETHER) && 2140 if ((dev->type != ARPHRD_ETHER) &&
2141 (dev->type != ARPHRD_FDDI) && 2141 (dev->type != ARPHRD_FDDI) &&
2142 (dev->type != ARPHRD_IEEE802_TR) && 2142 (dev->type != ARPHRD_IEEE802_TR) &&
2143 (dev->type != ARPHRD_ARCNET) && 2143 (dev->type != ARPHRD_ARCNET) &&
@@ -2164,9 +2164,9 @@ static void addrconf_sit_config(struct net_device *dev)
2164 2164
2165 ASSERT_RTNL(); 2165 ASSERT_RTNL();
2166 2166
2167 /* 2167 /*
2168 * Configure the tunnel with one of our IPv4 2168 * Configure the tunnel with one of our IPv4
2169 * addresses... we should configure all of 2169 * addresses... we should configure all of
2170 * our v4 addrs in the tunnel 2170 * our v4 addrs in the tunnel
2171 */ 2171 */
2172 2172
@@ -2233,7 +2233,7 @@ static void addrconf_ip6_tnl_config(struct net_device *dev)
2233 ip6_tnl_add_linklocal(idev); 2233 ip6_tnl_add_linklocal(idev);
2234} 2234}
2235 2235
2236static int addrconf_notify(struct notifier_block *this, unsigned long event, 2236static int addrconf_notify(struct notifier_block *this, unsigned long event,
2237 void * data) 2237 void * data)
2238{ 2238{
2239 struct net_device *dev = (struct net_device *) data; 2239 struct net_device *dev = (struct net_device *) data;
@@ -2378,7 +2378,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2378 return -ENODEV; 2378 return -ENODEV;
2379 2379
2380 /* Step 1: remove reference to ipv6 device from parent device. 2380 /* Step 1: remove reference to ipv6 device from parent device.
2381 Do not dev_put! 2381 Do not dev_put!
2382 */ 2382 */
2383 if (how == 1) { 2383 if (how == 1) {
2384 idev->dead = 1; 2384 idev->dead = 1;
@@ -2461,7 +2461,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2461 /* Step 5: netlink notification of this interface */ 2461 /* Step 5: netlink notification of this interface */
2462 idev->tstamp = jiffies; 2462 idev->tstamp = jiffies;
2463 inet6_ifinfo_notify(RTM_DELLINK, idev); 2463 inet6_ifinfo_notify(RTM_DELLINK, idev);
2464 2464
2465 /* Shot the device (if unregistered) */ 2465 /* Shot the device (if unregistered) */
2466 2466
2467 if (how == 1) { 2467 if (how == 1) {
@@ -2776,7 +2776,7 @@ out_kfree:
2776 goto out; 2776 goto out;
2777} 2777}
2778 2778
2779static struct file_operations if6_fops = { 2779static const struct file_operations if6_fops = {
2780 .owner = THIS_MODULE, 2780 .owner = THIS_MODULE,
2781 .open = if6_seq_open, 2781 .open = if6_seq_open,
2782 .read = seq_read, 2782 .read = seq_read,
@@ -2850,8 +2850,8 @@ restart:
2850 age = (now - ifp->tstamp) / HZ; 2850 age = (now - ifp->tstamp) / HZ;
2851 2851
2852#ifdef CONFIG_IPV6_PRIVACY 2852#ifdef CONFIG_IPV6_PRIVACY
2853 regen_advance = ifp->idev->cnf.regen_max_retry * 2853 regen_advance = ifp->idev->cnf.regen_max_retry *
2854 ifp->idev->cnf.dad_transmits * 2854 ifp->idev->cnf.dad_transmits *
2855 ifp->idev->nd_parms->retrans_time / HZ; 2855 ifp->idev->nd_parms->retrans_time / HZ;
2856#endif 2856#endif
2857 2857
@@ -3117,7 +3117,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
3117 3117
3118 nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags); 3118 nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
3119 if (nlh == NULL) 3119 if (nlh == NULL)
3120 return -ENOBUFS; 3120 return -EMSGSIZE;
3121 3121
3122 put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope), 3122 put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
3123 ifa->idev->dev->ifindex); 3123 ifa->idev->dev->ifindex);
@@ -3137,8 +3137,10 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
3137 } 3137 }
3138 3138
3139 if (nla_put(skb, IFA_ADDRESS, 16, &ifa->addr) < 0 || 3139 if (nla_put(skb, IFA_ADDRESS, 16, &ifa->addr) < 0 ||
3140 put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0) 3140 put_cacheinfo(skb, ifa->cstamp, ifa->tstamp, preferred, valid) < 0) {
3141 return nlmsg_cancel(skb, nlh); 3141 nlmsg_cancel(skb, nlh);
3142 return -EMSGSIZE;
3143 }
3142 3144
3143 return nlmsg_end(skb, nlh); 3145 return nlmsg_end(skb, nlh);
3144} 3146}
@@ -3155,13 +3157,15 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
3155 3157
3156 nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags); 3158 nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
3157 if (nlh == NULL) 3159 if (nlh == NULL)
3158 return -ENOBUFS; 3160 return -EMSGSIZE;
3159 3161
3160 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex); 3162 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
3161 if (nla_put(skb, IFA_MULTICAST, 16, &ifmca->mca_addr) < 0 || 3163 if (nla_put(skb, IFA_MULTICAST, 16, &ifmca->mca_addr) < 0 ||
3162 put_cacheinfo(skb, ifmca->mca_cstamp, ifmca->mca_tstamp, 3164 put_cacheinfo(skb, ifmca->mca_cstamp, ifmca->mca_tstamp,
3163 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) 3165 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
3164 return nlmsg_cancel(skb, nlh); 3166 nlmsg_cancel(skb, nlh);
3167 return -EMSGSIZE;
3168 }
3165 3169
3166 return nlmsg_end(skb, nlh); 3170 return nlmsg_end(skb, nlh);
3167} 3171}
@@ -3178,13 +3182,15 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
3178 3182
3179 nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags); 3183 nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
3180 if (nlh == NULL) 3184 if (nlh == NULL)
3181 return -ENOBUFS; 3185 return -EMSGSIZE;
3182 3186
3183 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex); 3187 put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
3184 if (nla_put(skb, IFA_ANYCAST, 16, &ifaca->aca_addr) < 0 || 3188 if (nla_put(skb, IFA_ANYCAST, 16, &ifaca->aca_addr) < 0 ||
3185 put_cacheinfo(skb, ifaca->aca_cstamp, ifaca->aca_tstamp, 3189 put_cacheinfo(skb, ifaca->aca_cstamp, ifaca->aca_tstamp,
3186 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) 3190 INFINITY_LIFE_TIME, INFINITY_LIFE_TIME) < 0) {
3187 return nlmsg_cancel(skb, nlh); 3191 nlmsg_cancel(skb, nlh);
3192 return -EMSGSIZE;
3193 }
3188 3194
3189 return nlmsg_end(skb, nlh); 3195 return nlmsg_end(skb, nlh);
3190} 3196}
@@ -3211,7 +3217,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3211 s_idx = cb->args[0]; 3217 s_idx = cb->args[0];
3212 s_ip_idx = ip_idx = cb->args[1]; 3218 s_ip_idx = ip_idx = cb->args[1];
3213 read_lock(&dev_base_lock); 3219 read_lock(&dev_base_lock);
3214 3220
3215 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 3221 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
3216 if (idx < s_idx) 3222 if (idx < s_idx)
3217 continue; 3223 continue;
@@ -3228,8 +3234,8 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3228 ifa = ifa->if_next, ip_idx++) { 3234 ifa = ifa->if_next, ip_idx++) {
3229 if (ip_idx < s_ip_idx) 3235 if (ip_idx < s_ip_idx)
3230 continue; 3236 continue;
3231 if ((err = inet6_fill_ifaddr(skb, ifa, 3237 if ((err = inet6_fill_ifaddr(skb, ifa,
3232 NETLINK_CB(cb->skb).pid, 3238 NETLINK_CB(cb->skb).pid,
3233 cb->nlh->nlmsg_seq, RTM_NEWADDR, 3239 cb->nlh->nlmsg_seq, RTM_NEWADDR,
3234 NLM_F_MULTI)) <= 0) 3240 NLM_F_MULTI)) <= 0)
3235 goto done; 3241 goto done;
@@ -3237,12 +3243,12 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3237 break; 3243 break;
3238 case MULTICAST_ADDR: 3244 case MULTICAST_ADDR:
3239 /* multicast address */ 3245 /* multicast address */
3240 for (ifmca = idev->mc_list; ifmca; 3246 for (ifmca = idev->mc_list; ifmca;
3241 ifmca = ifmca->next, ip_idx++) { 3247 ifmca = ifmca->next, ip_idx++) {
3242 if (ip_idx < s_ip_idx) 3248 if (ip_idx < s_ip_idx)
3243 continue; 3249 continue;
3244 if ((err = inet6_fill_ifmcaddr(skb, ifmca, 3250 if ((err = inet6_fill_ifmcaddr(skb, ifmca,
3245 NETLINK_CB(cb->skb).pid, 3251 NETLINK_CB(cb->skb).pid,
3246 cb->nlh->nlmsg_seq, RTM_GETMULTICAST, 3252 cb->nlh->nlmsg_seq, RTM_GETMULTICAST,
3247 NLM_F_MULTI)) <= 0) 3253 NLM_F_MULTI)) <= 0)
3248 goto done; 3254 goto done;
@@ -3254,10 +3260,10 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3254 ifaca = ifaca->aca_next, ip_idx++) { 3260 ifaca = ifaca->aca_next, ip_idx++) {
3255 if (ip_idx < s_ip_idx) 3261 if (ip_idx < s_ip_idx)
3256 continue; 3262 continue;
3257 if ((err = inet6_fill_ifacaddr(skb, ifaca, 3263 if ((err = inet6_fill_ifacaddr(skb, ifaca,
3258 NETLINK_CB(cb->skb).pid, 3264 NETLINK_CB(cb->skb).pid,
3259 cb->nlh->nlmsg_seq, RTM_GETANYCAST, 3265 cb->nlh->nlmsg_seq, RTM_GETANYCAST,
3260 NLM_F_MULTI)) <= 0) 3266 NLM_F_MULTI)) <= 0)
3261 goto done; 3267 goto done;
3262 } 3268 }
3263 break; 3269 break;
@@ -3334,9 +3340,12 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
3334 3340
3335 err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid, 3341 err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid,
3336 nlh->nlmsg_seq, RTM_NEWADDR, 0); 3342 nlh->nlmsg_seq, RTM_NEWADDR, 0);
3337 /* failure implies BUG in inet6_ifaddr_msgsize() */ 3343 if (err < 0) {
3338 BUG_ON(err < 0); 3344 /* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */
3339 3345 WARN_ON(err == -EMSGSIZE);
3346 kfree_skb(skb);
3347 goto errout_ifa;
3348 }
3340 err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid); 3349 err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
3341errout_ifa: 3350errout_ifa:
3342 in6_ifa_put(ifa); 3351 in6_ifa_put(ifa);
@@ -3354,9 +3363,12 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
3354 goto errout; 3363 goto errout;
3355 3364
3356 err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0); 3365 err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0);
3357 /* failure implies BUG in inet6_ifaddr_msgsize() */ 3366 if (err < 0) {
3358 BUG_ON(err < 0); 3367 /* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */
3359 3368 WARN_ON(err == -EMSGSIZE);
3369 kfree_skb(skb);
3370 goto errout;
3371 }
3360 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); 3372 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
3361errout: 3373errout:
3362 if (err < 0) 3374 if (err < 0)
@@ -3414,7 +3426,7 @@ static inline size_t inet6_if_nlmsg_size(void)
3414 ); 3426 );
3415} 3427}
3416 3428
3417static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, 3429static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
3418 u32 pid, u32 seq, int event, unsigned int flags) 3430 u32 pid, u32 seq, int event, unsigned int flags)
3419{ 3431{
3420 struct net_device *dev = idev->dev; 3432 struct net_device *dev = idev->dev;
@@ -3426,7 +3438,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
3426 3438
3427 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags); 3439 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
3428 if (nlh == NULL) 3440 if (nlh == NULL)
3429 return -ENOBUFS; 3441 return -EMSGSIZE;
3430 3442
3431 hdr = nlmsg_data(nlh); 3443 hdr = nlmsg_data(nlh);
3432 hdr->ifi_family = AF_INET6; 3444 hdr->ifi_family = AF_INET6;
@@ -3469,7 +3481,8 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
3469 return nlmsg_end(skb, nlh); 3481 return nlmsg_end(skb, nlh);
3470 3482
3471nla_put_failure: 3483nla_put_failure:
3472 return nlmsg_cancel(skb, nlh); 3484 nlmsg_cancel(skb, nlh);
3485 return -EMSGSIZE;
3473} 3486}
3474 3487
3475static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) 3488static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
@@ -3485,7 +3498,7 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
3485 continue; 3498 continue;
3486 if ((idev = in6_dev_get(dev)) == NULL) 3499 if ((idev = in6_dev_get(dev)) == NULL)
3487 continue; 3500 continue;
3488 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid, 3501 err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
3489 cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI); 3502 cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI);
3490 in6_dev_put(idev); 3503 in6_dev_put(idev);
3491 if (err <= 0) 3504 if (err <= 0)
@@ -3501,15 +3514,18 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
3501{ 3514{
3502 struct sk_buff *skb; 3515 struct sk_buff *skb;
3503 int err = -ENOBUFS; 3516 int err = -ENOBUFS;
3504 3517
3505 skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC); 3518 skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC);
3506 if (skb == NULL) 3519 if (skb == NULL)
3507 goto errout; 3520 goto errout;
3508 3521
3509 err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0); 3522 err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0);
3510 /* failure implies BUG in inet6_if_nlmsg_size() */ 3523 if (err < 0) {
3511 BUG_ON(err < 0); 3524 /* -EMSGSIZE implies BUG in inet6_if_nlmsg_size() */
3512 3525 WARN_ON(err == -EMSGSIZE);
3526 kfree_skb(skb);
3527 goto errout;
3528 }
3513 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); 3529 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
3514errout: 3530errout:
3515 if (err < 0) 3531 if (err < 0)
@@ -3533,7 +3549,7 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
3533 3549
3534 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*pmsg), flags); 3550 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*pmsg), flags);
3535 if (nlh == NULL) 3551 if (nlh == NULL)
3536 return -ENOBUFS; 3552 return -EMSGSIZE;
3537 3553
3538 pmsg = nlmsg_data(nlh); 3554 pmsg = nlmsg_data(nlh);
3539 pmsg->prefix_family = AF_INET6; 3555 pmsg->prefix_family = AF_INET6;
@@ -3558,10 +3574,11 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
3558 return nlmsg_end(skb, nlh); 3574 return nlmsg_end(skb, nlh);
3559 3575
3560nla_put_failure: 3576nla_put_failure:
3561 return nlmsg_cancel(skb, nlh); 3577 nlmsg_cancel(skb, nlh);
3578 return -EMSGSIZE;
3562} 3579}
3563 3580
3564static void inet6_prefix_notify(int event, struct inet6_dev *idev, 3581static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3565 struct prefix_info *pinfo) 3582 struct prefix_info *pinfo)
3566{ 3583{
3567 struct sk_buff *skb; 3584 struct sk_buff *skb;
@@ -3572,9 +3589,12 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3572 goto errout; 3589 goto errout;
3573 3590
3574 err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0); 3591 err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0);
3575 /* failure implies BUG in inet6_prefix_nlmsg_size() */ 3592 if (err < 0) {
3576 BUG_ON(err < 0); 3593 /* -EMSGSIZE implies BUG in inet6_prefix_nlmsg_size() */
3577 3594 WARN_ON(err == -EMSGSIZE);
3595 kfree_skb(skb);
3596 goto errout;
3597 }
3578 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC); 3598 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
3579errout: 3599errout:
3580 if (err < 0) 3600 if (err < 0)
@@ -3655,10 +3675,10 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
3655 rt6_purge_dflt_routers(); 3675 rt6_purge_dflt_routers();
3656 } 3676 }
3657 3677
3658 return ret; 3678 return ret;
3659} 3679}
3660 3680
3661static int addrconf_sysctl_forward_strategy(ctl_table *table, 3681static int addrconf_sysctl_forward_strategy(ctl_table *table,
3662 int __user *name, int nlen, 3682 int __user *name, int nlen,
3663 void __user *oldval, 3683 void __user *oldval,
3664 size_t __user *oldlenp, 3684 size_t __user *oldlenp,
@@ -3723,19 +3743,19 @@ static struct addrconf_sysctl_table
3723} addrconf_sysctl __read_mostly = { 3743} addrconf_sysctl __read_mostly = {
3724 .sysctl_header = NULL, 3744 .sysctl_header = NULL,
3725 .addrconf_vars = { 3745 .addrconf_vars = {
3726 { 3746 {
3727 .ctl_name = NET_IPV6_FORWARDING, 3747 .ctl_name = NET_IPV6_FORWARDING,
3728 .procname = "forwarding", 3748 .procname = "forwarding",
3729 .data = &ipv6_devconf.forwarding, 3749 .data = &ipv6_devconf.forwarding,
3730 .maxlen = sizeof(int), 3750 .maxlen = sizeof(int),
3731 .mode = 0644, 3751 .mode = 0644,
3732 .proc_handler = &addrconf_sysctl_forward, 3752 .proc_handler = &addrconf_sysctl_forward,
3733 .strategy = &addrconf_sysctl_forward_strategy, 3753 .strategy = &addrconf_sysctl_forward_strategy,
3734 }, 3754 },
3735 { 3755 {
3736 .ctl_name = NET_IPV6_HOP_LIMIT, 3756 .ctl_name = NET_IPV6_HOP_LIMIT,
3737 .procname = "hop_limit", 3757 .procname = "hop_limit",
3738 .data = &ipv6_devconf.hop_limit, 3758 .data = &ipv6_devconf.hop_limit,
3739 .maxlen = sizeof(int), 3759 .maxlen = sizeof(int),
3740 .mode = 0644, 3760 .mode = 0644,
3741 .proc_handler = proc_dointvec, 3761 .proc_handler = proc_dointvec,
@@ -3744,116 +3764,116 @@ static struct addrconf_sysctl_table
3744 .ctl_name = NET_IPV6_MTU, 3764 .ctl_name = NET_IPV6_MTU,
3745 .procname = "mtu", 3765 .procname = "mtu",
3746 .data = &ipv6_devconf.mtu6, 3766 .data = &ipv6_devconf.mtu6,
3747 .maxlen = sizeof(int), 3767 .maxlen = sizeof(int),
3748 .mode = 0644, 3768 .mode = 0644,
3749 .proc_handler = &proc_dointvec, 3769 .proc_handler = &proc_dointvec,
3750 }, 3770 },
3751 { 3771 {
3752 .ctl_name = NET_IPV6_ACCEPT_RA, 3772 .ctl_name = NET_IPV6_ACCEPT_RA,
3753 .procname = "accept_ra", 3773 .procname = "accept_ra",
3754 .data = &ipv6_devconf.accept_ra, 3774 .data = &ipv6_devconf.accept_ra,
3755 .maxlen = sizeof(int), 3775 .maxlen = sizeof(int),
3756 .mode = 0644, 3776 .mode = 0644,
3757 .proc_handler = &proc_dointvec, 3777 .proc_handler = &proc_dointvec,
3758 }, 3778 },
3759 { 3779 {
3760 .ctl_name = NET_IPV6_ACCEPT_REDIRECTS, 3780 .ctl_name = NET_IPV6_ACCEPT_REDIRECTS,
3761 .procname = "accept_redirects", 3781 .procname = "accept_redirects",
3762 .data = &ipv6_devconf.accept_redirects, 3782 .data = &ipv6_devconf.accept_redirects,
3763 .maxlen = sizeof(int), 3783 .maxlen = sizeof(int),
3764 .mode = 0644, 3784 .mode = 0644,
3765 .proc_handler = &proc_dointvec, 3785 .proc_handler = &proc_dointvec,
3766 }, 3786 },
3767 { 3787 {
3768 .ctl_name = NET_IPV6_AUTOCONF, 3788 .ctl_name = NET_IPV6_AUTOCONF,
3769 .procname = "autoconf", 3789 .procname = "autoconf",
3770 .data = &ipv6_devconf.autoconf, 3790 .data = &ipv6_devconf.autoconf,
3771 .maxlen = sizeof(int), 3791 .maxlen = sizeof(int),
3772 .mode = 0644, 3792 .mode = 0644,
3773 .proc_handler = &proc_dointvec, 3793 .proc_handler = &proc_dointvec,
3774 }, 3794 },
3775 { 3795 {
3776 .ctl_name = NET_IPV6_DAD_TRANSMITS, 3796 .ctl_name = NET_IPV6_DAD_TRANSMITS,
3777 .procname = "dad_transmits", 3797 .procname = "dad_transmits",
3778 .data = &ipv6_devconf.dad_transmits, 3798 .data = &ipv6_devconf.dad_transmits,
3779 .maxlen = sizeof(int), 3799 .maxlen = sizeof(int),
3780 .mode = 0644, 3800 .mode = 0644,
3781 .proc_handler = &proc_dointvec, 3801 .proc_handler = &proc_dointvec,
3782 }, 3802 },
3783 { 3803 {
3784 .ctl_name = NET_IPV6_RTR_SOLICITS, 3804 .ctl_name = NET_IPV6_RTR_SOLICITS,
3785 .procname = "router_solicitations", 3805 .procname = "router_solicitations",
3786 .data = &ipv6_devconf.rtr_solicits, 3806 .data = &ipv6_devconf.rtr_solicits,
3787 .maxlen = sizeof(int), 3807 .maxlen = sizeof(int),
3788 .mode = 0644, 3808 .mode = 0644,
3789 .proc_handler = &proc_dointvec, 3809 .proc_handler = &proc_dointvec,
3790 }, 3810 },
3791 { 3811 {
3792 .ctl_name = NET_IPV6_RTR_SOLICIT_INTERVAL, 3812 .ctl_name = NET_IPV6_RTR_SOLICIT_INTERVAL,
3793 .procname = "router_solicitation_interval", 3813 .procname = "router_solicitation_interval",
3794 .data = &ipv6_devconf.rtr_solicit_interval, 3814 .data = &ipv6_devconf.rtr_solicit_interval,
3795 .maxlen = sizeof(int), 3815 .maxlen = sizeof(int),
3796 .mode = 0644, 3816 .mode = 0644,
3797 .proc_handler = &proc_dointvec_jiffies, 3817 .proc_handler = &proc_dointvec_jiffies,
3798 .strategy = &sysctl_jiffies, 3818 .strategy = &sysctl_jiffies,
3799 }, 3819 },
3800 { 3820 {
3801 .ctl_name = NET_IPV6_RTR_SOLICIT_DELAY, 3821 .ctl_name = NET_IPV6_RTR_SOLICIT_DELAY,
3802 .procname = "router_solicitation_delay", 3822 .procname = "router_solicitation_delay",
3803 .data = &ipv6_devconf.rtr_solicit_delay, 3823 .data = &ipv6_devconf.rtr_solicit_delay,
3804 .maxlen = sizeof(int), 3824 .maxlen = sizeof(int),
3805 .mode = 0644, 3825 .mode = 0644,
3806 .proc_handler = &proc_dointvec_jiffies, 3826 .proc_handler = &proc_dointvec_jiffies,
3807 .strategy = &sysctl_jiffies, 3827 .strategy = &sysctl_jiffies,
3808 }, 3828 },
3809 { 3829 {
3810 .ctl_name = NET_IPV6_FORCE_MLD_VERSION, 3830 .ctl_name = NET_IPV6_FORCE_MLD_VERSION,
3811 .procname = "force_mld_version", 3831 .procname = "force_mld_version",
3812 .data = &ipv6_devconf.force_mld_version, 3832 .data = &ipv6_devconf.force_mld_version,
3813 .maxlen = sizeof(int), 3833 .maxlen = sizeof(int),
3814 .mode = 0644, 3834 .mode = 0644,
3815 .proc_handler = &proc_dointvec, 3835 .proc_handler = &proc_dointvec,
3816 }, 3836 },
3817#ifdef CONFIG_IPV6_PRIVACY 3837#ifdef CONFIG_IPV6_PRIVACY
3818 { 3838 {
3819 .ctl_name = NET_IPV6_USE_TEMPADDR, 3839 .ctl_name = NET_IPV6_USE_TEMPADDR,
3820 .procname = "use_tempaddr", 3840 .procname = "use_tempaddr",
3821 .data = &ipv6_devconf.use_tempaddr, 3841 .data = &ipv6_devconf.use_tempaddr,
3822 .maxlen = sizeof(int), 3842 .maxlen = sizeof(int),
3823 .mode = 0644, 3843 .mode = 0644,
3824 .proc_handler = &proc_dointvec, 3844 .proc_handler = &proc_dointvec,
3825 }, 3845 },
3826 { 3846 {
3827 .ctl_name = NET_IPV6_TEMP_VALID_LFT, 3847 .ctl_name = NET_IPV6_TEMP_VALID_LFT,
3828 .procname = "temp_valid_lft", 3848 .procname = "temp_valid_lft",
3829 .data = &ipv6_devconf.temp_valid_lft, 3849 .data = &ipv6_devconf.temp_valid_lft,
3830 .maxlen = sizeof(int), 3850 .maxlen = sizeof(int),
3831 .mode = 0644, 3851 .mode = 0644,
3832 .proc_handler = &proc_dointvec, 3852 .proc_handler = &proc_dointvec,
3833 }, 3853 },
3834 { 3854 {
3835 .ctl_name = NET_IPV6_TEMP_PREFERED_LFT, 3855 .ctl_name = NET_IPV6_TEMP_PREFERED_LFT,
3836 .procname = "temp_prefered_lft", 3856 .procname = "temp_prefered_lft",
3837 .data = &ipv6_devconf.temp_prefered_lft, 3857 .data = &ipv6_devconf.temp_prefered_lft,
3838 .maxlen = sizeof(int), 3858 .maxlen = sizeof(int),
3839 .mode = 0644, 3859 .mode = 0644,
3840 .proc_handler = &proc_dointvec, 3860 .proc_handler = &proc_dointvec,
3841 }, 3861 },
3842 { 3862 {
3843 .ctl_name = NET_IPV6_REGEN_MAX_RETRY, 3863 .ctl_name = NET_IPV6_REGEN_MAX_RETRY,
3844 .procname = "regen_max_retry", 3864 .procname = "regen_max_retry",
3845 .data = &ipv6_devconf.regen_max_retry, 3865 .data = &ipv6_devconf.regen_max_retry,
3846 .maxlen = sizeof(int), 3866 .maxlen = sizeof(int),
3847 .mode = 0644, 3867 .mode = 0644,
3848 .proc_handler = &proc_dointvec, 3868 .proc_handler = &proc_dointvec,
3849 }, 3869 },
3850 { 3870 {
3851 .ctl_name = NET_IPV6_MAX_DESYNC_FACTOR, 3871 .ctl_name = NET_IPV6_MAX_DESYNC_FACTOR,
3852 .procname = "max_desync_factor", 3872 .procname = "max_desync_factor",
3853 .data = &ipv6_devconf.max_desync_factor, 3873 .data = &ipv6_devconf.max_desync_factor,
3854 .maxlen = sizeof(int), 3874 .maxlen = sizeof(int),
3855 .mode = 0644, 3875 .mode = 0644,
3856 .proc_handler = &proc_dointvec, 3876 .proc_handler = &proc_dointvec,
3857 }, 3877 },
3858#endif 3878#endif
3859 { 3879 {
@@ -3867,18 +3887,18 @@ static struct addrconf_sysctl_table
3867 { 3887 {
3868 .ctl_name = NET_IPV6_ACCEPT_RA_DEFRTR, 3888 .ctl_name = NET_IPV6_ACCEPT_RA_DEFRTR,
3869 .procname = "accept_ra_defrtr", 3889 .procname = "accept_ra_defrtr",
3870 .data = &ipv6_devconf.accept_ra_defrtr, 3890 .data = &ipv6_devconf.accept_ra_defrtr,
3871 .maxlen = sizeof(int), 3891 .maxlen = sizeof(int),
3872 .mode = 0644, 3892 .mode = 0644,
3873 .proc_handler = &proc_dointvec, 3893 .proc_handler = &proc_dointvec,
3874 }, 3894 },
3875 { 3895 {
3876 .ctl_name = NET_IPV6_ACCEPT_RA_PINFO, 3896 .ctl_name = NET_IPV6_ACCEPT_RA_PINFO,
3877 .procname = "accept_ra_pinfo", 3897 .procname = "accept_ra_pinfo",
3878 .data = &ipv6_devconf.accept_ra_pinfo, 3898 .data = &ipv6_devconf.accept_ra_pinfo,
3879 .maxlen = sizeof(int), 3899 .maxlen = sizeof(int),
3880 .mode = 0644, 3900 .mode = 0644,
3881 .proc_handler = &proc_dointvec, 3901 .proc_handler = &proc_dointvec,
3882 }, 3902 },
3883#ifdef CONFIG_IPV6_ROUTER_PREF 3903#ifdef CONFIG_IPV6_ROUTER_PREF
3884 { 3904 {
@@ -3983,18 +4003,18 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf
3983 t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */ 4003 t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */
3984 } 4004 }
3985 if (dev) { 4005 if (dev) {
3986 dev_name = dev->name; 4006 dev_name = dev->name;
3987 t->addrconf_dev[0].ctl_name = dev->ifindex; 4007 t->addrconf_dev[0].ctl_name = dev->ifindex;
3988 } else { 4008 } else {
3989 dev_name = "default"; 4009 dev_name = "default";
3990 t->addrconf_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT; 4010 t->addrconf_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT;
3991 } 4011 }
3992 4012
3993 /* 4013 /*
3994 * Make a copy of dev_name, because '.procname' is regarded as const 4014 * Make a copy of dev_name, because '.procname' is regarded as const
3995 * by sysctl and we wouldn't want anyone to change it under our feet 4015 * by sysctl and we wouldn't want anyone to change it under our feet
3996 * (see SIOCSIFNAME). 4016 * (see SIOCSIFNAME).
3997 */ 4017 */
3998 dev_name = kstrdup(dev_name, GFP_KERNEL); 4018 dev_name = kstrdup(dev_name, GFP_KERNEL);
3999 if (!dev_name) 4019 if (!dev_name)
4000 goto free; 4020 goto free;
@@ -4046,12 +4066,12 @@ static void addrconf_sysctl_unregister(struct ipv6_devconf *p)
4046 4066
4047int register_inet6addr_notifier(struct notifier_block *nb) 4067int register_inet6addr_notifier(struct notifier_block *nb)
4048{ 4068{
4049 return atomic_notifier_chain_register(&inet6addr_chain, nb); 4069 return atomic_notifier_chain_register(&inet6addr_chain, nb);
4050} 4070}
4051 4071
4052int unregister_inet6addr_notifier(struct notifier_block *nb) 4072int unregister_inet6addr_notifier(struct notifier_block *nb)
4053{ 4073{
4054 return atomic_notifier_chain_unregister(&inet6addr_chain,nb); 4074 return atomic_notifier_chain_unregister(&inet6addr_chain,nb);
4055} 4075}
4056 4076
4057/* 4077/*
@@ -4104,9 +4124,9 @@ int __init addrconf_init(void)
4104 4124
4105void __exit addrconf_cleanup(void) 4125void __exit addrconf_cleanup(void)
4106{ 4126{
4107 struct net_device *dev; 4127 struct net_device *dev;
4108 struct inet6_dev *idev; 4128 struct inet6_dev *idev;
4109 struct inet6_ifaddr *ifa; 4129 struct inet6_ifaddr *ifa;
4110 int i; 4130 int i;
4111 4131
4112 unregister_netdevice_notifier(&ipv6_dev_notf); 4132 unregister_netdevice_notifier(&ipv6_dev_notf);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 0e0e4262f4dc..a006d242be76 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * PF_INET6 socket protocol family 2 * PF_INET6 socket protocol family
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * Adapted from linux/net/ipv4/af_inet.c 8 * Adapted from linux/net/ipv4/af_inet.c
9 * 9 *
@@ -191,7 +191,7 @@ lookup_protocol:
191 np->mc_loop = 1; 191 np->mc_loop = 1;
192 np->pmtudisc = IPV6_PMTUDISC_WANT; 192 np->pmtudisc = IPV6_PMTUDISC_WANT;
193 np->ipv6only = sysctl_ipv6_bindv6only; 193 np->ipv6only = sysctl_ipv6_bindv6only;
194 194
195 /* Init the ipv4 part of the socket since we can have sockets 195 /* Init the ipv4 part of the socket since we can have sockets
196 * using v6 API for ipv4. 196 * using v6 API for ipv4.
197 */ 197 */
@@ -206,7 +206,7 @@ lookup_protocol:
206 inet->pmtudisc = IP_PMTUDISC_DONT; 206 inet->pmtudisc = IP_PMTUDISC_DONT;
207 else 207 else
208 inet->pmtudisc = IP_PMTUDISC_WANT; 208 inet->pmtudisc = IP_PMTUDISC_WANT;
209 /* 209 /*
210 * Increment only the relevant sk_prot->socks debug field, this changes 210 * Increment only the relevant sk_prot->socks debug field, this changes
211 * the previous behaviour of incrementing both the equivalent to 211 * the previous behaviour of incrementing both the equivalent to
212 * answer->prot->socks (inet6_sock_nr) and inet_sock_nr. 212 * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
@@ -293,7 +293,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
293 */ 293 */
294 sk->sk_bound_dev_if = addr->sin6_scope_id; 294 sk->sk_bound_dev_if = addr->sin6_scope_id;
295 } 295 }
296 296
297 /* Binding to link-local address requires an interface */ 297 /* Binding to link-local address requires an interface */
298 if (!sk->sk_bound_dev_if) { 298 if (!sk->sk_bound_dev_if) {
299 err = -EINVAL; 299 err = -EINVAL;
@@ -327,7 +327,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
327 inet->saddr = v4addr; 327 inet->saddr = v4addr;
328 328
329 ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr); 329 ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr);
330 330
331 if (!(addr_type & IPV6_ADDR_MULTICAST)) 331 if (!(addr_type & IPV6_ADDR_MULTICAST))
332 ipv6_addr_copy(&np->saddr, &addr->sin6_addr); 332 ipv6_addr_copy(&np->saddr, &addr->sin6_addr);
333 333
@@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(inet6_destroy_sock);
393/* 393/*
394 * This does both peername and sockname. 394 * This does both peername and sockname.
395 */ 395 */
396 396
397int inet6_getname(struct socket *sock, struct sockaddr *uaddr, 397int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
398 int *uaddr_len, int peer) 398 int *uaddr_len, int peer)
399{ 399{
@@ -401,7 +401,7 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
401 struct sock *sk = sock->sk; 401 struct sock *sk = sock->sk;
402 struct inet_sock *inet = inet_sk(sk); 402 struct inet_sock *inet = inet_sk(sk);
403 struct ipv6_pinfo *np = inet6_sk(sk); 403 struct ipv6_pinfo *np = inet6_sk(sk);
404 404
405 sin->sin6_family = AF_INET6; 405 sin->sin6_family = AF_INET6;
406 sin->sin6_flowinfo = 0; 406 sin->sin6_flowinfo = 0;
407 sin->sin6_scope_id = 0; 407 sin->sin6_scope_id = 0;
@@ -433,14 +433,14 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
433{ 433{
434 struct sock *sk = sock->sk; 434 struct sock *sk = sock->sk;
435 435
436 switch(cmd) 436 switch(cmd)
437 { 437 {
438 case SIOCGSTAMP: 438 case SIOCGSTAMP:
439 return sock_get_timestamp(sk, (struct timeval __user *)arg); 439 return sock_get_timestamp(sk, (struct timeval __user *)arg);
440 440
441 case SIOCADDRT: 441 case SIOCADDRT:
442 case SIOCDELRT: 442 case SIOCDELRT:
443 443
444 return(ipv6_route_ioctl(cmd,(void __user *)arg)); 444 return(ipv6_route_ioctl(cmd,(void __user *)arg));
445 445
446 case SIOCSIFADDR: 446 case SIOCSIFADDR:
@@ -584,7 +584,7 @@ inet6_register_protosw(struct inet_protosw *p)
584 /* Add the new entry after the last permanent entry if any, so that 584 /* Add the new entry after the last permanent entry if any, so that
585 * the new entry does not override a permanent entry when matched with 585 * the new entry does not override a permanent entry when matched with
586 * a wild-card protocol. But it is allowed to override any existing 586 * a wild-card protocol. But it is allowed to override any existing
587 * non-permanent entry. This means that when we remove this entry, the 587 * non-permanent entry. This means that when we remove this entry, the
588 * system automatically returns to the old behavior. 588 * system automatically returns to the old behavior.
589 */ 589 */
590 list_add_rcu(&p->list, last_perm); 590 list_add_rcu(&p->list, last_perm);
@@ -749,7 +749,7 @@ err_icmp_mib:
749 snmp6_mib_free((void **)ipv6_statistics); 749 snmp6_mib_free((void **)ipv6_statistics);
750err_ip_mib: 750err_ip_mib:
751 return -ENOMEM; 751 return -ENOMEM;
752 752
753} 753}
754 754
755static void cleanup_ipv6_mibs(void) 755static void cleanup_ipv6_mibs(void)
@@ -763,7 +763,7 @@ static void cleanup_ipv6_mibs(void)
763static int __init inet6_init(void) 763static int __init inet6_init(void)
764{ 764{
765 struct sk_buff *dummy_skb; 765 struct sk_buff *dummy_skb;
766 struct list_head *r; 766 struct list_head *r;
767 int err; 767 int err;
768 768
769 BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb)); 769 BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb));
@@ -814,7 +814,7 @@ static int __init inet6_init(void)
814 err = init_ipv6_mibs(); 814 err = init_ipv6_mibs();
815 if (err) 815 if (err)
816 goto out_unregister_sock; 816 goto out_unregister_sock;
817 817
818 /* 818 /*
819 * ipngwg API draft makes clear that the correct semantics 819 * ipngwg API draft makes clear that the correct semantics
820 * for TCP and UDP is to consider one TCP and UDP instance 820 * for TCP and UDP is to consider one TCP and UDP instance
@@ -933,11 +933,11 @@ static void __exit inet6_exit(void)
933#ifdef CONFIG_PROC_FS 933#ifdef CONFIG_PROC_FS
934 if6_proc_exit(); 934 if6_proc_exit();
935 ac6_proc_exit(); 935 ac6_proc_exit();
936 ipv6_misc_proc_exit(); 936 ipv6_misc_proc_exit();
937 udp6_proc_exit(); 937 udp6_proc_exit();
938 udplite6_proc_exit(); 938 udplite6_proc_exit();
939 tcp6_proc_exit(); 939 tcp6_proc_exit();
940 raw6_proc_exit(); 940 raw6_proc_exit();
941#endif 941#endif
942#ifdef CONFIG_IPV6_MIP6 942#ifdef CONFIG_IPV6_MIP6
943 mip6_fini(); 943 mip6_fini();
@@ -952,7 +952,7 @@ static void __exit inet6_exit(void)
952 ndisc_cleanup(); 952 ndisc_cleanup();
953 icmpv6_cleanup(); 953 icmpv6_cleanup();
954#ifdef CONFIG_SYSCTL 954#ifdef CONFIG_SYSCTL
955 ipv6_sysctl_unregister(); 955 ipv6_sysctl_unregister();
956#endif 956#endif
957 cleanup_ipv6_mibs(); 957 cleanup_ipv6_mibs();
958 proto_unregister(&rawv6_prot); 958 proto_unregister(&rawv6_prot);
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 12c5a4dec09e..dc68b7269c3c 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -1,26 +1,26 @@
1/* 1/*
2 * Copyright (C)2002 USAGI/WIDE Project 2 * Copyright (C)2002 USAGI/WIDE Project
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * 17 *
18 * Authors 18 * Authors
19 * 19 *
20 * Mitsuru KANDA @USAGI : IPv6 Support 20 * Mitsuru KANDA @USAGI : IPv6 Support
21 * Kazunori MIYAZAWA @USAGI : 21 * Kazunori MIYAZAWA @USAGI :
22 * Kunihiro Ishiguro <kunihiro@ipinfusion.com> 22 * Kunihiro Ishiguro <kunihiro@ipinfusion.com>
23 * 23 *
24 * This file is derived from net/ipv4/ah.c. 24 * This file is derived from net/ipv4/ah.c.
25 */ 25 */
26 26
@@ -54,7 +54,7 @@ static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
54 optlen = 1; 54 optlen = 1;
55 break; 55 break;
56 default: 56 default:
57 if (len < 2) 57 if (len < 2)
58 goto bad; 58 goto bad;
59 optlen = opt[off+1]+2; 59 optlen = opt[off+1]+2;
60 if (len < optlen) 60 if (len < optlen)
@@ -152,7 +152,7 @@ static void ipv6_rearrange_rthdr(struct ipv6hdr *iph, struct ipv6_rt_hdr *rthdr)
152 segments_left = rthdr->segments_left; 152 segments_left = rthdr->segments_left;
153 if (segments_left == 0) 153 if (segments_left == 0)
154 return; 154 return;
155 rthdr->segments_left = 0; 155 rthdr->segments_left = 0;
156 156
157 /* The value of rthdr->hdrlen has been verified either by the system 157 /* The value of rthdr->hdrlen has been verified either by the system
158 * call if it is locally generated, or by ipv6_rthdr_rcv() for incoming 158 * call if it is locally generated, or by ipv6_rthdr_rcv() for incoming
@@ -278,7 +278,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
278 top_iph->hop_limit = 0; 278 top_iph->hop_limit = 0;
279 279
280 ahp = x->data; 280 ahp = x->data;
281 ah->hdrlen = (XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + 281 ah->hdrlen = (XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) +
282 ahp->icv_trunc_len) >> 2) - 2; 282 ahp->icv_trunc_len) >> 2) - 2;
283 283
284 ah->reserved = 0; 284 ah->reserved = 0;
@@ -319,7 +319,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
319 * Moving the pointer of skb->nh.raw by using skb_pull as long as AH 319 * Moving the pointer of skb->nh.raw by using skb_pull as long as AH
320 * header length. Then copy back the copy as long as hdr_len 320 * header length. Then copy back the copy as long as hdr_len
321 * If destination header following AH exists, copy it into after [Ext2]. 321 * If destination header following AH exists, copy it into after [Ext2].
322 * 322 *
323 * |<>|[IPv6][Ext1][Ext2][Dest][Payload] 323 * |<>|[IPv6][Ext1][Ext2][Dest][Payload]
324 * There is offset of AH before IPv6 header after the process. 324 * There is offset of AH before IPv6 header after the process.
325 */ 325 */
@@ -347,9 +347,9 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
347 nexthdr = ah->nexthdr; 347 nexthdr = ah->nexthdr;
348 ah_hlen = (ah->hdrlen + 2) << 2; 348 ah_hlen = (ah->hdrlen + 2) << 2;
349 349
350 if (ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_full_len) && 350 if (ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_full_len) &&
351 ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len)) 351 ah_hlen != XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len))
352 goto out; 352 goto out;
353 353
354 if (!pskb_may_pull(skb, ah_hlen)) 354 if (!pskb_may_pull(skb, ah_hlen))
355 goto out; 355 goto out;
@@ -365,7 +365,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
365 skb->nh.ipv6h->flow_lbl[2] = 0; 365 skb->nh.ipv6h->flow_lbl[2] = 0;
366 skb->nh.ipv6h->hop_limit = 0; 366 skb->nh.ipv6h->hop_limit = 0;
367 367
368 { 368 {
369 u8 auth_data[MAX_AH_AUTH_LEN]; 369 u8 auth_data[MAX_AH_AUTH_LEN];
370 370
371 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len); 371 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
@@ -395,8 +395,8 @@ out:
395 return err; 395 return err;
396} 396}
397 397
398static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 398static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
399 int type, int code, int offset, __be32 info) 399 int type, int code, int offset, __be32 info)
400{ 400{
401 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 401 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
402 struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset); 402 struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset);
@@ -445,7 +445,7 @@ static int ah6_init_state(struct xfrm_state *x)
445 ahp->tfm = tfm; 445 ahp->tfm = tfm;
446 if (crypto_hash_setkey(tfm, ahp->key, ahp->key_len)) 446 if (crypto_hash_setkey(tfm, ahp->key, ahp->key_len))
447 goto error; 447 goto error;
448 448
449 /* 449 /*
450 * Lookup the algorithm description maintained by xfrm_algo, 450 * Lookup the algorithm description maintained by xfrm_algo,
451 * verify crypto transform properties, and store information 451 * verify crypto transform properties, and store information
@@ -462,16 +462,16 @@ static int ah6_init_state(struct xfrm_state *x)
462 aalg_desc->uinfo.auth.icv_fullbits/8); 462 aalg_desc->uinfo.auth.icv_fullbits/8);
463 goto error; 463 goto error;
464 } 464 }
465 465
466 ahp->icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8; 466 ahp->icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;
467 ahp->icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8; 467 ahp->icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8;
468 468
469 BUG_ON(ahp->icv_trunc_len > MAX_AH_AUTH_LEN); 469 BUG_ON(ahp->icv_trunc_len > MAX_AH_AUTH_LEN);
470 470
471 ahp->work_icv = kmalloc(ahp->icv_full_len, GFP_KERNEL); 471 ahp->work_icv = kmalloc(ahp->icv_full_len, GFP_KERNEL);
472 if (!ahp->work_icv) 472 if (!ahp->work_icv)
473 goto error; 473 goto error;
474 474
475 x->props.header_len = XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len); 475 x->props.header_len = XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len);
476 if (x->props.mode == XFRM_MODE_TUNNEL) 476 if (x->props.mode == XFRM_MODE_TUNNEL)
477 x->props.header_len += sizeof(struct ipv6hdr); 477 x->props.header_len += sizeof(struct ipv6hdr);
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index a9604764e015..6fb2e9d716c0 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Anycast support for IPv6 2 * Anycast support for IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * David L Stevens (dlstevens@us.ibm.com) 6 * David L Stevens (dlstevens@us.ibm.com)
@@ -397,7 +397,7 @@ static int ipv6_dev_ac_dec(struct net_device *dev, struct in6_addr *addr)
397 in6_dev_put(idev); 397 in6_dev_put(idev);
398 return ret; 398 return ret;
399} 399}
400 400
401/* 401/*
402 * check if the interface has this anycast address 402 * check if the interface has this anycast address
403 */ 403 */
@@ -565,7 +565,7 @@ out_kfree:
565 goto out; 565 goto out;
566} 566}
567 567
568static struct file_operations ac6_seq_fops = { 568static const struct file_operations ac6_seq_fops = {
569 .owner = THIS_MODULE, 569 .owner = THIS_MODULE,
570 .open = ac6_seq_open, 570 .open = ac6_seq_open,
571 .read = seq_read, 571 .read = seq_read,
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 5c94fea90e97..5f54dec3e205 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * common UDP/RAW code 2 * common UDP/RAW code
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: datagram.c,v 1.24 2002/02/01 22:01:04 davem Exp $ 8 * $Id: datagram.c,v 1.24 2002/02/01 22:01:04 davem Exp $
9 * 9 *
@@ -55,10 +55,10 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
55 } 55 }
56 56
57 if (addr_len < SIN6_LEN_RFC2133) 57 if (addr_len < SIN6_LEN_RFC2133)
58 return -EINVAL; 58 return -EINVAL;
59 59
60 if (usin->sin6_family != AF_INET6) 60 if (usin->sin6_family != AF_INET6)
61 return -EAFNOSUPPORT; 61 return -EAFNOSUPPORT;
62 62
63 memset(&fl, 0, sizeof(fl)); 63 memset(&fl, 0, sizeof(fl));
64 if (np->sndflow) { 64 if (np->sndflow) {
@@ -93,14 +93,14 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
93 sin.sin_addr.s_addr = daddr->s6_addr32[3]; 93 sin.sin_addr.s_addr = daddr->s6_addr32[3];
94 sin.sin_port = usin->sin6_port; 94 sin.sin_port = usin->sin6_port;
95 95
96 err = ip4_datagram_connect(sk, 96 err = ip4_datagram_connect(sk,
97 (struct sockaddr*) &sin, 97 (struct sockaddr*) &sin,
98 sizeof(sin)); 98 sizeof(sin));
99 99
100ipv4_connected: 100ipv4_connected:
101 if (err) 101 if (err)
102 goto out; 102 goto out;
103 103
104 ipv6_addr_set(&np->daddr, 0, 0, htonl(0x0000ffff), inet->daddr); 104 ipv6_addr_set(&np->daddr, 0, 0, htonl(0x0000ffff), inet->daddr);
105 105
106 if (ipv6_addr_any(&np->saddr)) { 106 if (ipv6_addr_any(&np->saddr)) {
@@ -178,7 +178,7 @@ ipv4_connected:
178 if (final_p) 178 if (final_p)
179 ipv6_addr_copy(&fl.fl6_dst, final_p); 179 ipv6_addr_copy(&fl.fl6_dst, final_p);
180 180
181 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) 181 if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
182 goto out; 182 goto out;
183 183
184 /* source address lookup done in ip6_dst_lookup */ 184 /* source address lookup done in ip6_dst_lookup */
@@ -206,7 +206,7 @@ out:
206 return err; 206 return err;
207} 207}
208 208
209void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 209void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
210 __be16 port, u32 info, u8 *payload) 210 __be16 port, u32 info, u8 *payload)
211{ 211{
212 struct ipv6_pinfo *np = inet6_sk(sk); 212 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -223,7 +223,7 @@ void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
223 serr = SKB_EXT_ERR(skb); 223 serr = SKB_EXT_ERR(skb);
224 serr->ee.ee_errno = err; 224 serr->ee.ee_errno = err;
225 serr->ee.ee_origin = SO_EE_ORIGIN_ICMP6; 225 serr->ee.ee_origin = SO_EE_ORIGIN_ICMP6;
226 serr->ee.ee_type = icmph->icmp6_type; 226 serr->ee.ee_type = icmph->icmp6_type;
227 serr->ee.ee_code = icmph->icmp6_code; 227 serr->ee.ee_code = icmph->icmp6_code;
228 serr->ee.ee_pad = 0; 228 serr->ee.ee_pad = 0;
229 serr->ee.ee_info = info; 229 serr->ee.ee_info = info;
@@ -259,7 +259,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
259 serr = SKB_EXT_ERR(skb); 259 serr = SKB_EXT_ERR(skb);
260 serr->ee.ee_errno = err; 260 serr->ee.ee_errno = err;
261 serr->ee.ee_origin = SO_EE_ORIGIN_LOCAL; 261 serr->ee.ee_origin = SO_EE_ORIGIN_LOCAL;
262 serr->ee.ee_type = 0; 262 serr->ee.ee_type = 0;
263 serr->ee.ee_code = 0; 263 serr->ee.ee_code = 0;
264 serr->ee.ee_pad = 0; 264 serr->ee.ee_pad = 0;
265 serr->ee.ee_info = info; 265 serr->ee.ee_info = info;
@@ -274,7 +274,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
274 kfree_skb(skb); 274 kfree_skb(skb);
275} 275}
276 276
277/* 277/*
278 * Handle MSG_ERRQUEUE 278 * Handle MSG_ERRQUEUE
279 */ 279 */
280int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) 280int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
@@ -312,7 +312,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
312 if (sin) { 312 if (sin) {
313 sin->sin6_family = AF_INET6; 313 sin->sin6_family = AF_INET6;
314 sin->sin6_flowinfo = 0; 314 sin->sin6_flowinfo = 0;
315 sin->sin6_port = serr->port; 315 sin->sin6_port = serr->port;
316 sin->sin6_scope_id = 0; 316 sin->sin6_scope_id = 0;
317 if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) { 317 if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
318 ipv6_addr_copy(&sin->sin6_addr, 318 ipv6_addr_copy(&sin->sin6_addr,
@@ -370,7 +370,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
370 spin_unlock_bh(&sk->sk_error_queue.lock); 370 spin_unlock_bh(&sk->sk_error_queue.lock);
371 } 371 }
372 372
373out_free_skb: 373out_free_skb:
374 kfree_skb(skb); 374 kfree_skb(skb);
375out: 375out:
376 return err; 376 return err;
@@ -419,7 +419,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
419 * report extension headers (except for HbH) 419 * report extension headers (except for HbH)
420 * in order. 420 * in order.
421 * 421 *
422 * Also note that IPV6_RECVRTHDRDSTOPTS is NOT 422 * Also note that IPV6_RECVRTHDRDSTOPTS is NOT
423 * (and WILL NOT be) defined because 423 * (and WILL NOT be) defined because
424 * IPV6_RECVDSTOPTS is more generic. --yoshfuji 424 * IPV6_RECVDSTOPTS is more generic. --yoshfuji
425 */ 425 */
@@ -512,15 +512,15 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
512 continue; 512 continue;
513 513
514 switch (cmsg->cmsg_type) { 514 switch (cmsg->cmsg_type) {
515 case IPV6_PKTINFO: 515 case IPV6_PKTINFO:
516 case IPV6_2292PKTINFO: 516 case IPV6_2292PKTINFO:
517 if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) { 517 if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct in6_pktinfo))) {
518 err = -EINVAL; 518 err = -EINVAL;
519 goto exit_f; 519 goto exit_f;
520 } 520 }
521 521
522 src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg); 522 src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);
523 523
524 if (src_info->ipi6_ifindex) { 524 if (src_info->ipi6_ifindex) {
525 if (fl->oif && src_info->ipi6_ifindex != fl->oif) 525 if (fl->oif && src_info->ipi6_ifindex != fl->oif)
526 return -EINVAL; 526 return -EINVAL;
@@ -531,7 +531,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
531 531
532 if (addr_type == IPV6_ADDR_ANY) 532 if (addr_type == IPV6_ADDR_ANY)
533 break; 533 break;
534 534
535 if (addr_type & IPV6_ADDR_LINKLOCAL) { 535 if (addr_type & IPV6_ADDR_LINKLOCAL) {
536 if (!src_info->ipi6_ifindex) 536 if (!src_info->ipi6_ifindex)
537 return -EINVAL; 537 return -EINVAL;
@@ -554,7 +554,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
554 break; 554 break;
555 555
556 case IPV6_FLOWINFO: 556 case IPV6_FLOWINFO:
557 if (cmsg->cmsg_len < CMSG_LEN(4)) { 557 if (cmsg->cmsg_len < CMSG_LEN(4)) {
558 err = -EINVAL; 558 err = -EINVAL;
559 goto exit_f; 559 goto exit_f;
560 } 560 }
@@ -570,7 +570,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
570 570
571 case IPV6_2292HOPOPTS: 571 case IPV6_2292HOPOPTS:
572 case IPV6_HOPOPTS: 572 case IPV6_HOPOPTS:
573 if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { 573 if (opt->hopopt || cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) {
574 err = -EINVAL; 574 err = -EINVAL;
575 goto exit_f; 575 goto exit_f;
576 } 576 }
@@ -590,7 +590,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
590 break; 590 break;
591 591
592 case IPV6_2292DSTOPTS: 592 case IPV6_2292DSTOPTS:
593 if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) { 593 if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_opt_hdr))) {
594 err = -EINVAL; 594 err = -EINVAL;
595 goto exit_f; 595 goto exit_f;
596 } 596 }
@@ -641,7 +641,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
641 641
642 case IPV6_2292RTHDR: 642 case IPV6_2292RTHDR:
643 case IPV6_RTHDR: 643 case IPV6_RTHDR:
644 if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) { 644 if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct ipv6_rt_hdr))) {
645 err = -EINVAL; 645 err = -EINVAL;
646 goto exit_f; 646 goto exit_f;
647 } 647 }
@@ -661,7 +661,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
661 661
662 len = ((rthdr->hdrlen + 1) << 3); 662 len = ((rthdr->hdrlen + 1) << 3);
663 663
664 if (cmsg->cmsg_len < CMSG_LEN(len)) { 664 if (cmsg->cmsg_len < CMSG_LEN(len)) {
665 err = -EINVAL; 665 err = -EINVAL;
666 goto exit_f; 666 goto exit_f;
667 } 667 }
@@ -716,7 +716,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
716 } 716 }
717 default: 717 default:
718 LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", 718 LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n",
719 cmsg->cmsg_type); 719 cmsg->cmsg_type);
720 err = -EINVAL; 720 err = -EINVAL;
721 break; 721 break;
722 }; 722 };
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 25dcf69cd807..363e63ffecca 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -1,26 +1,26 @@
1/* 1/*
2 * Copyright (C)2002 USAGI/WIDE Project 2 * Copyright (C)2002 USAGI/WIDE Project
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * 17 *
18 * Authors 18 * Authors
19 * 19 *
20 * Mitsuru KANDA @USAGI : IPv6 Support 20 * Mitsuru KANDA @USAGI : IPv6 Support
21 * Kazunori MIYAZAWA @USAGI : 21 * Kazunori MIYAZAWA @USAGI :
22 * Kunihiro Ishiguro <kunihiro@ipinfusion.com> 22 * Kunihiro Ishiguro <kunihiro@ipinfusion.com>
23 * 23 *
24 * This file is derived from net/ipv4/esp.c 24 * This file is derived from net/ipv4/esp.c
25 */ 25 */
26 26
@@ -166,7 +166,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
166 } 166 }
167 167
168 /* If integrity check is required, do this. */ 168 /* If integrity check is required, do this. */
169 if (esp->auth.icv_full_len) { 169 if (esp->auth.icv_full_len) {
170 u8 sum[alen]; 170 u8 sum[alen];
171 171
172 ret = esp_mac_digest(esp, skb, 0, skb->len - alen); 172 ret = esp_mac_digest(esp, skb, 0, skb->len - alen);
@@ -197,7 +197,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
197 if (esp->conf.ivlen) 197 if (esp->conf.ivlen)
198 crypto_blkcipher_set_iv(tfm, esph->enc_data, esp->conf.ivlen); 198 crypto_blkcipher_set_iv(tfm, esph->enc_data, esp->conf.ivlen);
199 199
200 { 200 {
201 u8 nexthdr[2]; 201 u8 nexthdr[2];
202 struct scatterlist *sg = &esp->sgbuf[0]; 202 struct scatterlist *sg = &esp->sgbuf[0];
203 u8 padlen; 203 u8 padlen;
@@ -225,7 +225,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
225 ret = -EINVAL; 225 ret = -EINVAL;
226 goto out; 226 goto out;
227 } 227 }
228 /* ... check padding bits here. Silly. :-) */ 228 /* ... check padding bits here. Silly. :-) */
229 229
230 pskb_trim(skb, skb->len - alen - padlen - 2); 230 pskb_trim(skb, skb->len - alen - padlen - 2);
231 ret = nexthdr[1]; 231 ret = nexthdr[1];
@@ -256,20 +256,20 @@ static u32 esp6_get_max_size(struct xfrm_state *x, int mtu)
256} 256}
257 257
258static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 258static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
259 int type, int code, int offset, __be32 info) 259 int type, int code, int offset, __be32 info)
260{ 260{
261 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 261 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
262 struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset); 262 struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset);
263 struct xfrm_state *x; 263 struct xfrm_state *x;
264 264
265 if (type != ICMPV6_DEST_UNREACH && 265 if (type != ICMPV6_DEST_UNREACH &&
266 type != ICMPV6_PKT_TOOBIG) 266 type != ICMPV6_PKT_TOOBIG)
267 return; 267 return;
268 268
269 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6); 269 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6);
270 if (!x) 270 if (!x)
271 return; 271 return;
272 printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/" NIP6_FMT "\n", 272 printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/" NIP6_FMT "\n",
273 ntohl(esph->spi), NIP6(iph->daddr)); 273 ntohl(esph->spi), NIP6(iph->daddr));
274 xfrm_state_put(x); 274 xfrm_state_put(x);
275} 275}
@@ -326,10 +326,10 @@ static int esp6_init_state(struct xfrm_state *x)
326 esp->auth.tfm = hash; 326 esp->auth.tfm = hash;
327 if (crypto_hash_setkey(hash, esp->auth.key, esp->auth.key_len)) 327 if (crypto_hash_setkey(hash, esp->auth.key, esp->auth.key_len))
328 goto error; 328 goto error;
329 329
330 aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0); 330 aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0);
331 BUG_ON(!aalg_desc); 331 BUG_ON(!aalg_desc);
332 332
333 if (aalg_desc->uinfo.auth.icv_fullbits/8 != 333 if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
334 crypto_hash_digestsize(hash)) { 334 crypto_hash_digestsize(hash)) {
335 NETDEBUG(KERN_INFO "ESP: %s digestsize %u != %hu\n", 335 NETDEBUG(KERN_INFO "ESP: %s digestsize %u != %hu\n",
@@ -338,10 +338,10 @@ static int esp6_init_state(struct xfrm_state *x)
338 aalg_desc->uinfo.auth.icv_fullbits/8); 338 aalg_desc->uinfo.auth.icv_fullbits/8);
339 goto error; 339 goto error;
340 } 340 }
341 341
342 esp->auth.icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8; 342 esp->auth.icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;
343 esp->auth.icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8; 343 esp->auth.icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8;
344 344
345 esp->auth.work_icv = kmalloc(esp->auth.icv_full_len, GFP_KERNEL); 345 esp->auth.work_icv = kmalloc(esp->auth.icv_full_len, GFP_KERNEL);
346 if (!esp->auth.work_icv) 346 if (!esp->auth.work_icv)
347 goto error; 347 goto error;
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 0711f92d6a12..08313efc48c8 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -16,7 +16,7 @@
16 */ 16 */
17 17
18/* Changes: 18/* Changes:
19 * yoshfuji : ensure not to overrun while parsing 19 * yoshfuji : ensure not to overrun while parsing
20 * tlv options. 20 * tlv options.
21 * Mitsuru KANDA @USAGI and: Remove ipv6_parse_exthdrs(). 21 * Mitsuru KANDA @USAGI and: Remove ipv6_parse_exthdrs().
22 * YOSHIFUJI Hideaki @USAGI Register inbound extension header 22 * YOSHIFUJI Hideaki @USAGI Register inbound extension header
@@ -167,8 +167,8 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff **skbp)
167 goto bad; 167 goto bad;
168 for (curr=procs; curr->type >= 0; curr++) { 168 for (curr=procs; curr->type >= 0; curr++) {
169 if (curr->type == skb->nh.raw[off]) { 169 if (curr->type == skb->nh.raw[off]) {
170 /* type specific length/alignment 170 /* type specific length/alignment
171 checks will be performed in the 171 checks will be performed in the
172 func(). */ 172 func(). */
173 if (curr->func(skbp, off) == 0) 173 if (curr->func(skbp, off) == 0)
174 return 0; 174 return 0;
@@ -572,7 +572,7 @@ void __init ipv6_rthdr_init(void)
572 For now we need to test the engine, so that I created 572 For now we need to test the engine, so that I created
573 temporary (or permanent) backdoor. 573 temporary (or permanent) backdoor.
574 If listening socket set IPV6_RTHDR to 2, then we invert header. 574 If listening socket set IPV6_RTHDR to 2, then we invert header.
575 --ANK (980729) 575 --ANK (980729)
576 */ 576 */
577 577
578struct ipv6_txoptions * 578struct ipv6_txoptions *
@@ -635,7 +635,7 @@ static int ipv6_hop_ra(struct sk_buff **skbp, int optoff)
635 return 1; 635 return 1;
636 } 636 }
637 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", 637 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
638 skb->nh.raw[optoff+1]); 638 skb->nh.raw[optoff+1]);
639 kfree_skb(skb); 639 kfree_skb(skb);
640 return 0; 640 return 0;
641} 641}
@@ -649,7 +649,7 @@ static int ipv6_hop_jumbo(struct sk_buff **skbp, int optoff)
649 649
650 if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) { 650 if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) {
651 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", 651 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
652 skb->nh.raw[optoff+1]); 652 skb->nh.raw[optoff+1]);
653 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), 653 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
654 IPSTATS_MIB_INHDRERRORS); 654 IPSTATS_MIB_INHDRERRORS);
655 goto drop; 655 goto drop;
@@ -740,7 +740,7 @@ static void ipv6_push_rthdr(struct sk_buff *skb, u8 *proto,
740 int hops; 740 int hops;
741 741
742 ihdr = (struct rt0_hdr *) opt; 742 ihdr = (struct rt0_hdr *) opt;
743 743
744 phdr = (struct rt0_hdr *) skb_push(skb, (ihdr->rt_hdr.hdrlen + 1) << 3); 744 phdr = (struct rt0_hdr *) skb_push(skb, (ihdr->rt_hdr.hdrlen + 1) << 3);
745 memcpy(phdr, ihdr, sizeof(struct rt0_hdr)); 745 memcpy(phdr, ihdr, sizeof(struct rt0_hdr));
746 746
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 21cbbbddaf4d..e1caa5d526c2 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -4,13 +4,13 @@
4 */ 4 */
5#include <net/ipv6.h> 5#include <net/ipv6.h>
6 6
7/* 7/*
8 * find out if nexthdr is a well-known extension header or a protocol 8 * find out if nexthdr is a well-known extension header or a protocol
9 */ 9 */
10 10
11int ipv6_ext_hdr(u8 nexthdr) 11int ipv6_ext_hdr(u8 nexthdr)
12{ 12{
13 /* 13 /*
14 * find out if nexthdr is an extension header or a protocol 14 * find out if nexthdr is an extension header or a protocol
15 */ 15 */
16 return ( (nexthdr == NEXTHDR_HOP) || 16 return ( (nexthdr == NEXTHDR_HOP) ||
@@ -25,18 +25,18 @@ int ipv6_ext_hdr(u8 nexthdr)
25 * Skip any extension headers. This is used by the ICMP module. 25 * Skip any extension headers. This is used by the ICMP module.
26 * 26 *
27 * Note that strictly speaking this conflicts with RFC 2460 4.0: 27 * Note that strictly speaking this conflicts with RFC 2460 4.0:
28 * ...The contents and semantics of each extension header determine whether 28 * ...The contents and semantics of each extension header determine whether
29 * or not to proceed to the next header. Therefore, extension headers must 29 * or not to proceed to the next header. Therefore, extension headers must
30 * be processed strictly in the order they appear in the packet; a 30 * be processed strictly in the order they appear in the packet; a
31 * receiver must not, for example, scan through a packet looking for a 31 * receiver must not, for example, scan through a packet looking for a
32 * particular kind of extension header and process that header prior to 32 * particular kind of extension header and process that header prior to
33 * processing all preceding ones. 33 * processing all preceding ones.
34 * 34 *
35 * We do exactly this. This is a protocol bug. We can't decide after a 35 * We do exactly this. This is a protocol bug. We can't decide after a
36 * seeing an unknown discard-with-error flavour TLV option if it's a 36 * seeing an unknown discard-with-error flavour TLV option if it's a
37 * ICMP error message or not (errors should never be send in reply to 37 * ICMP error message or not (errors should never be send in reply to
38 * ICMP error messages). 38 * ICMP error messages).
39 * 39 *
40 * But I see no other way to do this. This might need to be reexamined 40 * But I see no other way to do this. This might need to be reexamined
41 * when Linux implements ESP (and maybe AUTH) headers. 41 * when Linux implements ESP (and maybe AUTH) headers.
42 * --AK 42 * --AK
@@ -90,9 +90,9 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp)
90 break; 90 break;
91 hdrlen = 8; 91 hdrlen = 8;
92 } else if (nexthdr == NEXTHDR_AUTH) 92 } else if (nexthdr == NEXTHDR_AUTH)
93 hdrlen = (hp->hdrlen+2)<<2; 93 hdrlen = (hp->hdrlen+2)<<2;
94 else 94 else
95 hdrlen = ipv6_optlen(hp); 95 hdrlen = ipv6_optlen(hp);
96 96
97 nexthdr = hp->nexthdr; 97 nexthdr = hp->nexthdr;
98 start += hdrlen; 98 start += hdrlen;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 3dcc4b7f41b4..9377fea02682 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -107,7 +107,7 @@ static __inline__ void icmpv6_xmit_unlock(void)
107 spin_unlock_bh(&icmpv6_socket->sk->sk_lock.slock); 107 spin_unlock_bh(&icmpv6_socket->sk->sk_lock.slock);
108} 108}
109 109
110/* 110/*
111 * Slightly more convenient version of icmpv6_send. 111 * Slightly more convenient version of icmpv6_send.
112 */ 112 */
113void icmpv6_param_prob(struct sk_buff *skb, int code, int pos) 113void icmpv6_param_prob(struct sk_buff *skb, int code, int pos)
@@ -153,8 +153,8 @@ static int is_ineligible(struct sk_buff *skb)
153 153
154static int sysctl_icmpv6_time __read_mostly = 1*HZ; 154static int sysctl_icmpv6_time __read_mostly = 1*HZ;
155 155
156/* 156/*
157 * Check the ICMP output rate limit 157 * Check the ICMP output rate limit
158 */ 158 */
159static inline int icmpv6_xrlim_allow(struct sock *sk, int type, 159static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
160 struct flowi *fl) 160 struct flowi *fl)
@@ -170,7 +170,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
170 if (type == ICMPV6_PKT_TOOBIG) 170 if (type == ICMPV6_PKT_TOOBIG)
171 return 1; 171 return 1;
172 172
173 /* 173 /*
174 * Look up the output route. 174 * Look up the output route.
175 * XXX: perhaps the expire for routing entries cloned by 175 * XXX: perhaps the expire for routing entries cloned by
176 * this lookup should be more aggressive (not longer than timeout). 176 * this lookup should be more aggressive (not longer than timeout).
@@ -198,7 +198,7 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
198/* 198/*
199 * an inline helper for the "simple" if statement below 199 * an inline helper for the "simple" if statement below
200 * checks if parameter problem report is caused by an 200 * checks if parameter problem report is caused by an
201 * unrecognized IPv6 option that has the Option Type 201 * unrecognized IPv6 option that has the Option Type
202 * highest-order two bits set to 10 202 * highest-order two bits set to 10
203 */ 203 */
204 204
@@ -298,7 +298,7 @@ static inline void mip6_addr_swap(struct sk_buff *skb) {}
298/* 298/*
299 * Send an ICMP message in response to a packet in error 299 * Send an ICMP message in response to a packet in error
300 */ 300 */
301void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, 301void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
302 struct net_device *dev) 302 struct net_device *dev)
303{ 303{
304 struct inet6_dev *idev = NULL; 304 struct inet6_dev *idev = NULL;
@@ -320,7 +320,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
320 return; 320 return;
321 321
322 /* 322 /*
323 * Make sure we respect the rules 323 * Make sure we respect the rules
324 * i.e. RFC 1885 2.4(e) 324 * i.e. RFC 1885 2.4(e)
325 * Rule (e.1) is enforced by not using icmpv6_send 325 * Rule (e.1) is enforced by not using icmpv6_send
326 * in any code that processes icmp errors. 326 * in any code that processes icmp errors.
@@ -336,8 +336,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
336 336
337 if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) { 337 if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) {
338 if (type != ICMPV6_PKT_TOOBIG && 338 if (type != ICMPV6_PKT_TOOBIG &&
339 !(type == ICMPV6_PARAMPROB && 339 !(type == ICMPV6_PARAMPROB &&
340 code == ICMPV6_UNK_OPTION && 340 code == ICMPV6_UNK_OPTION &&
341 (opt_unrec(skb, info)))) 341 (opt_unrec(skb, info))))
342 return; 342 return;
343 343
@@ -364,7 +364,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
364 return; 364 return;
365 } 365 }
366 366
367 /* 367 /*
368 * Never answer to a ICMP packet. 368 * Never answer to a ICMP packet.
369 */ 369 */
370 if (is_ineligible(skb)) { 370 if (is_ineligible(skb)) {
@@ -543,14 +543,14 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
543 } 543 }
544 err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr)); 544 err = icmpv6_push_pending_frames(sk, &fl, &tmp_hdr, skb->len + sizeof(struct icmp6hdr));
545 545
546 ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES); 546 ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTECHOREPLIES);
547 ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS); 547 ICMP6_INC_STATS_BH(idev, ICMP6_MIB_OUTMSGS);
548 548
549out_put: 549out_put:
550 if (likely(idev != NULL)) 550 if (likely(idev != NULL))
551 in6_dev_put(idev); 551 in6_dev_put(idev);
552 dst_release(dst); 552 dst_release(dst);
553out: 553out:
554 icmpv6_xmit_unlock(); 554 icmpv6_xmit_unlock();
555} 555}
556 556
@@ -608,7 +608,7 @@ static void icmpv6_notify(struct sk_buff *skb, int type, int code, __be32 info)
608 } 608 }
609 read_unlock(&raw_v6_lock); 609 read_unlock(&raw_v6_lock);
610} 610}
611 611
612/* 612/*
613 * Handle icmp messages 613 * Handle icmp messages
614 */ 614 */
@@ -722,9 +722,9 @@ static int icmpv6_rcv(struct sk_buff **pskb)
722 if (type & ICMPV6_INFOMSG_MASK) 722 if (type & ICMPV6_INFOMSG_MASK)
723 break; 723 break;
724 724
725 /* 725 /*
726 * error of unknown type. 726 * error of unknown type.
727 * must pass to upper level 727 * must pass to upper level
728 */ 728 */
729 729
730 icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu); 730 icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu);
@@ -852,7 +852,7 @@ int icmpv6_err_convert(int type, int code, int *err)
852 case ICMPV6_PKT_TOOBIG: 852 case ICMPV6_PKT_TOOBIG:
853 *err = EMSGSIZE; 853 *err = EMSGSIZE;
854 break; 854 break;
855 855
856 case ICMPV6_PARAMPROB: 856 case ICMPV6_PARAMPROB:
857 *err = EPROTO; 857 *err = EPROTO;
858 fatal = 1; 858 fatal = 1;
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index b7e5bae0e347..30b16da739c2 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -79,7 +79,7 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
79 goto hit; /* You sunk my battleship! */ 79 goto hit; /* You sunk my battleship! */
80 } 80 }
81 /* Must check for a TIME_WAIT'er before going to listener hash. */ 81 /* Must check for a TIME_WAIT'er before going to listener hash. */
82 sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) { 82 sk_for_each(sk, node, &head->twchain) {
83 const struct inet_timewait_sock *tw = inet_twsk(sk); 83 const struct inet_timewait_sock *tw = inet_twsk(sk);
84 84
85 if(*((__portpair *)&(tw->tw_dport)) == ports && 85 if(*((__portpair *)&(tw->tw_dport)) == ports &&
@@ -115,7 +115,7 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
115 sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { 115 sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) {
116 if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) { 116 if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) {
117 const struct ipv6_pinfo *np = inet6_sk(sk); 117 const struct ipv6_pinfo *np = inet6_sk(sk);
118 118
119 score = 1; 119 score = 1;
120 if (!ipv6_addr_any(&np->rcv_saddr)) { 120 if (!ipv6_addr_any(&np->rcv_saddr)) {
121 if (!ipv6_addr_equal(&np->rcv_saddr, daddr)) 121 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
@@ -183,7 +183,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
183 write_lock(&head->lock); 183 write_lock(&head->lock);
184 184
185 /* Check TIME-WAIT sockets first. */ 185 /* Check TIME-WAIT sockets first. */
186 sk_for_each(sk2, node, &(head + hinfo->ehash_size)->chain) { 186 sk_for_each(sk2, node, &head->twchain) {
187 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); 187 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2);
188 188
189 tw = inet_twsk(sk2); 189 tw = inet_twsk(sk2);
@@ -249,81 +249,81 @@ int inet6_hash_connect(struct inet_timewait_death_row *death_row,
249{ 249{
250 struct inet_hashinfo *hinfo = death_row->hashinfo; 250 struct inet_hashinfo *hinfo = death_row->hashinfo;
251 const unsigned short snum = inet_sk(sk)->num; 251 const unsigned short snum = inet_sk(sk)->num;
252 struct inet_bind_hashbucket *head; 252 struct inet_bind_hashbucket *head;
253 struct inet_bind_bucket *tb; 253 struct inet_bind_bucket *tb;
254 int ret; 254 int ret;
255 255
256 if (snum == 0) { 256 if (snum == 0) {
257 const int low = sysctl_local_port_range[0]; 257 const int low = sysctl_local_port_range[0];
258 const int high = sysctl_local_port_range[1]; 258 const int high = sysctl_local_port_range[1];
259 const int range = high - low; 259 const int range = high - low;
260 int i, port; 260 int i, port;
261 static u32 hint; 261 static u32 hint;
262 const u32 offset = hint + inet6_sk_port_offset(sk); 262 const u32 offset = hint + inet6_sk_port_offset(sk);
263 struct hlist_node *node; 263 struct hlist_node *node;
264 struct inet_timewait_sock *tw = NULL; 264 struct inet_timewait_sock *tw = NULL;
265 265
266 local_bh_disable(); 266 local_bh_disable();
267 for (i = 1; i <= range; i++) { 267 for (i = 1; i <= range; i++) {
268 port = low + (i + offset) % range; 268 port = low + (i + offset) % range;
269 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; 269 head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)];
270 spin_lock(&head->lock); 270 spin_lock(&head->lock);
271 271
272 /* Does not bother with rcv_saddr checks, 272 /* Does not bother with rcv_saddr checks,
273 * because the established check is already 273 * because the established check is already
274 * unique enough. 274 * unique enough.
275 */ 275 */
276 inet_bind_bucket_for_each(tb, node, &head->chain) { 276 inet_bind_bucket_for_each(tb, node, &head->chain) {
277 if (tb->port == port) { 277 if (tb->port == port) {
278 BUG_TRAP(!hlist_empty(&tb->owners)); 278 BUG_TRAP(!hlist_empty(&tb->owners));
279 if (tb->fastreuse >= 0) 279 if (tb->fastreuse >= 0)
280 goto next_port; 280 goto next_port;
281 if (!__inet6_check_established(death_row, 281 if (!__inet6_check_established(death_row,
282 sk, port, 282 sk, port,
283 &tw)) 283 &tw))
284 goto ok; 284 goto ok;
285 goto next_port; 285 goto next_port;
286 } 286 }
287 } 287 }
288 288
289 tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, 289 tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep,
290 head, port); 290 head, port);
291 if (!tb) { 291 if (!tb) {
292 spin_unlock(&head->lock); 292 spin_unlock(&head->lock);
293 break; 293 break;
294 } 294 }
295 tb->fastreuse = -1; 295 tb->fastreuse = -1;
296 goto ok; 296 goto ok;
297 297
298 next_port: 298 next_port:
299 spin_unlock(&head->lock); 299 spin_unlock(&head->lock);
300 } 300 }
301 local_bh_enable(); 301 local_bh_enable();
302 302
303 return -EADDRNOTAVAIL; 303 return -EADDRNOTAVAIL;
304 304
305ok: 305ok:
306 hint += i; 306 hint += i;
307 307
308 /* Head lock still held and bh's disabled */ 308 /* Head lock still held and bh's disabled */
309 inet_bind_hash(sk, tb, port); 309 inet_bind_hash(sk, tb, port);
310 if (sk_unhashed(sk)) { 310 if (sk_unhashed(sk)) {
311 inet_sk(sk)->sport = htons(port); 311 inet_sk(sk)->sport = htons(port);
312 __inet6_hash(hinfo, sk); 312 __inet6_hash(hinfo, sk);
313 } 313 }
314 spin_unlock(&head->lock); 314 spin_unlock(&head->lock);
315 315
316 if (tw) { 316 if (tw) {
317 inet_twsk_deschedule(tw, death_row); 317 inet_twsk_deschedule(tw, death_row);
318 inet_twsk_put(tw); 318 inet_twsk_put(tw);
319 } 319 }
320 320
321 ret = 0; 321 ret = 0;
322 goto out; 322 goto out;
323 } 323 }
324 324
325 head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)]; 325 head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)];
326 tb = inet_csk(sk)->icsk_bind_hash; 326 tb = inet_csk(sk)->icsk_bind_hash;
327 spin_lock_bh(&head->lock); 327 spin_lock_bh(&head->lock);
328 328
329 if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { 329 if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) {
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 96d8310ae9c8..f4d7be77eb0f 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * Linux INET6 implementation 2 * Linux INET6 implementation
3 * Forwarding Information Database 3 * Forwarding Information Database
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: ip6_fib.c,v 1.25 2001/10/31 21:55:55 davem Exp $ 8 * $Id: ip6_fib.c,v 1.25 2001/10/31 21:55:55 davem Exp $
9 * 9 *
@@ -97,7 +97,7 @@ static DEFINE_TIMER(ip6_fib_timer, fib6_run_gc, 0, 0);
97 97
98static struct fib6_walker_t fib6_walker_list = { 98static struct fib6_walker_t fib6_walker_list = {
99 .prev = &fib6_walker_list, 99 .prev = &fib6_walker_list,
100 .next = &fib6_walker_list, 100 .next = &fib6_walker_list,
101}; 101};
102 102
103#define FOR_WALKERS(w) for ((w)=fib6_walker_list.next; (w) != &fib6_walker_list; (w)=(w)->next) 103#define FOR_WALKERS(w) for ((w)=fib6_walker_list.next; (w) != &fib6_walker_list; (w)=(w)->next)
@@ -131,7 +131,7 @@ static __inline__ u32 fib6_new_sernum(void)
131/* 131/*
132 * Auxiliary address test functions for the radix tree. 132 * Auxiliary address test functions for the radix tree.
133 * 133 *
134 * These assume a 32bit processor (although it will work on 134 * These assume a 32bit processor (although it will work on
135 * 64bit processors) 135 * 64bit processors)
136 */ 136 */
137 137
@@ -150,8 +150,7 @@ static __inline__ struct fib6_node * node_alloc(void)
150{ 150{
151 struct fib6_node *fn; 151 struct fib6_node *fn;
152 152
153 if ((fn = kmem_cache_alloc(fib6_node_kmem, GFP_ATOMIC)) != NULL) 153 fn = kmem_cache_zalloc(fib6_node_kmem, GFP_ATOMIC);
154 memset(fn, 0, sizeof(struct fib6_node));
155 154
156 return fn; 155 return fn;
157} 156}
@@ -298,7 +297,7 @@ static int fib6_dump_node(struct fib6_walker_t *w)
298 int res; 297 int res;
299 struct rt6_info *rt; 298 struct rt6_info *rt;
300 299
301 for (rt = w->leaf; rt; rt = rt->u.next) { 300 for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
302 res = rt6_dump_route(rt, w->args); 301 res = rt6_dump_route(rt, w->args);
303 if (res < 0) { 302 if (res < 0) {
304 /* Frame is full, suspend walking */ 303 /* Frame is full, suspend walking */
@@ -434,7 +433,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
434 struct fib6_node *pn = NULL; 433 struct fib6_node *pn = NULL;
435 struct rt6key *key; 434 struct rt6key *key;
436 int bit; 435 int bit;
437 __be32 dir = 0; 436 __be32 dir = 0;
438 __u32 sernum = fib6_new_sernum(); 437 __u32 sernum = fib6_new_sernum();
439 438
440 RT6_TRACE("fib6_add_1\n"); 439 RT6_TRACE("fib6_add_1\n");
@@ -452,27 +451,27 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
452 if (plen < fn->fn_bit || 451 if (plen < fn->fn_bit ||
453 !ipv6_prefix_equal(&key->addr, addr, fn->fn_bit)) 452 !ipv6_prefix_equal(&key->addr, addr, fn->fn_bit))
454 goto insert_above; 453 goto insert_above;
455 454
456 /* 455 /*
457 * Exact match ? 456 * Exact match ?
458 */ 457 */
459 458
460 if (plen == fn->fn_bit) { 459 if (plen == fn->fn_bit) {
461 /* clean up an intermediate node */ 460 /* clean up an intermediate node */
462 if ((fn->fn_flags & RTN_RTINFO) == 0) { 461 if ((fn->fn_flags & RTN_RTINFO) == 0) {
463 rt6_release(fn->leaf); 462 rt6_release(fn->leaf);
464 fn->leaf = NULL; 463 fn->leaf = NULL;
465 } 464 }
466 465
467 fn->fn_sernum = sernum; 466 fn->fn_sernum = sernum;
468 467
469 return fn; 468 return fn;
470 } 469 }
471 470
472 /* 471 /*
473 * We have more bits to go 472 * We have more bits to go
474 */ 473 */
475 474
476 /* Try to walk down on tree. */ 475 /* Try to walk down on tree. */
477 fn->fn_sernum = sernum; 476 fn->fn_sernum = sernum;
478 dir = addr_bit_set(addr, fn->fn_bit); 477 dir = addr_bit_set(addr, fn->fn_bit);
@@ -490,7 +489,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
490 if (ln == NULL) 489 if (ln == NULL)
491 return NULL; 490 return NULL;
492 ln->fn_bit = plen; 491 ln->fn_bit = plen;
493 492
494 ln->parent = pn; 493 ln->parent = pn;
495 ln->fn_sernum = sernum; 494 ln->fn_sernum = sernum;
496 495
@@ -504,7 +503,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
504 503
505insert_above: 504insert_above:
506 /* 505 /*
507 * split since we don't have a common prefix anymore or 506 * split since we don't have a common prefix anymore or
508 * we have a less significant route. 507 * we have a less significant route.
509 * we've to insert an intermediate node on the list 508 * we've to insert an intermediate node on the list
510 * this new node will point to the one we need to create 509 * this new node will point to the one we need to create
@@ -518,18 +517,18 @@ insert_above:
518 See comment in __ipv6_addr_diff: bit may be an invalid value, 517 See comment in __ipv6_addr_diff: bit may be an invalid value,
519 but if it is >= plen, the value is ignored in any case. 518 but if it is >= plen, the value is ignored in any case.
520 */ 519 */
521 520
522 bit = __ipv6_addr_diff(addr, &key->addr, addrlen); 521 bit = __ipv6_addr_diff(addr, &key->addr, addrlen);
523 522
524 /* 523 /*
525 * (intermediate)[in] 524 * (intermediate)[in]
526 * / \ 525 * / \
527 * (new leaf node)[ln] (old node)[fn] 526 * (new leaf node)[ln] (old node)[fn]
528 */ 527 */
529 if (plen > bit) { 528 if (plen > bit) {
530 in = node_alloc(); 529 in = node_alloc();
531 ln = node_alloc(); 530 ln = node_alloc();
532 531
533 if (in == NULL || ln == NULL) { 532 if (in == NULL || ln == NULL) {
534 if (in) 533 if (in)
535 node_free(in); 534 node_free(in);
@@ -538,8 +537,8 @@ insert_above:
538 return NULL; 537 return NULL;
539 } 538 }
540 539
541 /* 540 /*
542 * new intermediate node. 541 * new intermediate node.
543 * RTN_RTINFO will 542 * RTN_RTINFO will
544 * be off since that an address that chooses one of 543 * be off since that an address that chooses one of
545 * the branches would not match less specific routes 544 * the branches would not match less specific routes
@@ -576,7 +575,7 @@ insert_above:
576 } 575 }
577 } else { /* plen <= bit */ 576 } else { /* plen <= bit */
578 577
579 /* 578 /*
580 * (new leaf node)[ln] 579 * (new leaf node)[ln]
581 * / \ 580 * / \
582 * (old node)[fn] NULL 581 * (old node)[fn] NULL
@@ -592,7 +591,7 @@ insert_above:
592 ln->parent = pn; 591 ln->parent = pn;
593 592
594 ln->fn_sernum = sernum; 593 ln->fn_sernum = sernum;
595 594
596 if (dir) 595 if (dir)
597 pn->right = ln; 596 pn->right = ln;
598 else 597 else
@@ -624,11 +623,11 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
624 fn->leaf == &ip6_null_entry && 623 fn->leaf == &ip6_null_entry &&
625 !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){ 624 !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){
626 fn->leaf = rt; 625 fn->leaf = rt;
627 rt->u.next = NULL; 626 rt->u.dst.rt6_next = NULL;
628 goto out; 627 goto out;
629 } 628 }
630 629
631 for (iter = fn->leaf; iter; iter=iter->u.next) { 630 for (iter = fn->leaf; iter; iter=iter->u.dst.rt6_next) {
632 /* 631 /*
633 * Search for duplicates 632 * Search for duplicates
634 */ 633 */
@@ -656,7 +655,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
656 if (iter->rt6i_metric > rt->rt6i_metric) 655 if (iter->rt6i_metric > rt->rt6i_metric)
657 break; 656 break;
658 657
659 ins = &iter->u.next; 658 ins = &iter->u.dst.rt6_next;
660 } 659 }
661 660
662 /* 661 /*
@@ -664,7 +663,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
664 */ 663 */
665 664
666out: 665out:
667 rt->u.next = iter; 666 rt->u.dst.rt6_next = iter;
668 *ins = rt; 667 *ins = rt;
669 rt->rt6i_node = fn; 668 rt->rt6i_node = fn;
670 atomic_inc(&rt->rt6i_ref); 669 atomic_inc(&rt->rt6i_ref);
@@ -1105,7 +1104,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
1105 RT6_TRACE("fib6_del_route\n"); 1104 RT6_TRACE("fib6_del_route\n");
1106 1105
1107 /* Unlink it */ 1106 /* Unlink it */
1108 *rtp = rt->u.next; 1107 *rtp = rt->u.dst.rt6_next;
1109 rt->rt6i_node = NULL; 1108 rt->rt6i_node = NULL;
1110 rt6_stats.fib_rt_entries--; 1109 rt6_stats.fib_rt_entries--;
1111 rt6_stats.fib_discarded_routes++; 1110 rt6_stats.fib_discarded_routes++;
@@ -1115,14 +1114,14 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
1115 FOR_WALKERS(w) { 1114 FOR_WALKERS(w) {
1116 if (w->state == FWS_C && w->leaf == rt) { 1115 if (w->state == FWS_C && w->leaf == rt) {
1117 RT6_TRACE("walker %p adjusted by delroute\n", w); 1116 RT6_TRACE("walker %p adjusted by delroute\n", w);
1118 w->leaf = rt->u.next; 1117 w->leaf = rt->u.dst.rt6_next;
1119 if (w->leaf == NULL) 1118 if (w->leaf == NULL)
1120 w->state = FWS_U; 1119 w->state = FWS_U;
1121 } 1120 }
1122 } 1121 }
1123 read_unlock(&fib6_walker_lock); 1122 read_unlock(&fib6_walker_lock);
1124 1123
1125 rt->u.next = NULL; 1124 rt->u.dst.rt6_next = NULL;
1126 1125
1127 if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT) 1126 if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
1128 fn->leaf = &ip6_null_entry; 1127 fn->leaf = &ip6_null_entry;
@@ -1190,7 +1189,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
1190 * Walk the leaf entries looking for ourself 1189 * Walk the leaf entries looking for ourself
1191 */ 1190 */
1192 1191
1193 for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) { 1192 for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.dst.rt6_next) {
1194 if (*rtp == rt) { 1193 if (*rtp == rt) {
1195 fib6_del_route(fn, rtp, info); 1194 fib6_del_route(fn, rtp, info);
1196 return 0; 1195 return 0;
@@ -1206,7 +1205,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
1206 * However, it is internally reenterable wrt itself and fib6_add/fib6_del. 1205 * However, it is internally reenterable wrt itself and fib6_add/fib6_del.
1207 * It means, that we can modify tree during walking 1206 * It means, that we can modify tree during walking
1208 * and use this function for garbage collection, clone pruning, 1207 * and use this function for garbage collection, clone pruning,
1209 * cleaning tree when a device goes down etc. etc. 1208 * cleaning tree when a device goes down etc. etc.
1210 * 1209 *
1211 * It guarantees that every node will be traversed, 1210 * It guarantees that every node will be traversed,
1212 * and that it will be traversed only once. 1211 * and that it will be traversed only once.
@@ -1245,7 +1244,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
1245 continue; 1244 continue;
1246 } 1245 }
1247 w->state = FWS_L; 1246 w->state = FWS_L;
1248#endif 1247#endif
1249 case FWS_L: 1248 case FWS_L:
1250 if (fn->left) { 1249 if (fn->left) {
1251 w->node = fn->left; 1250 w->node = fn->left;
@@ -1317,7 +1316,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
1317 struct rt6_info *rt; 1316 struct rt6_info *rt;
1318 struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w; 1317 struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w;
1319 1318
1320 for (rt = w->leaf; rt; rt = rt->u.next) { 1319 for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
1321 res = c->func(rt, c->arg); 1320 res = c->func(rt, c->arg);
1322 if (res < 0) { 1321 if (res < 0) {
1323 w->leaf = rt; 1322 w->leaf = rt;
@@ -1338,7 +1337,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
1338 1337
1339/* 1338/*
1340 * Convenient frontend to tree walker. 1339 * Convenient frontend to tree walker.
1341 * 1340 *
1342 * func is called on each route. 1341 * func is called on each route.
1343 * It may return -1 -> delete this route. 1342 * It may return -1 -> delete this route.
1344 * 0 -> continue walking 1343 * 0 -> continue walking
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 624fae251f4e..c206a152ed9d 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -228,10 +228,10 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space,
228 struct ipv6_txoptions * fopt) 228 struct ipv6_txoptions * fopt)
229{ 229{
230 struct ipv6_txoptions * fl_opt = fl->opt; 230 struct ipv6_txoptions * fl_opt = fl->opt;
231 231
232 if (fopt == NULL || fopt->opt_flen == 0) 232 if (fopt == NULL || fopt->opt_flen == 0)
233 return fl_opt; 233 return fl_opt;
234 234
235 if (fl_opt != NULL) { 235 if (fl_opt != NULL) {
236 opt_space->hopopt = fl_opt->hopopt; 236 opt_space->hopopt = fl_opt->hopopt;
237 opt_space->dst0opt = fl_opt->dst0opt; 237 opt_space->dst0opt = fl_opt->dst0opt;
@@ -677,7 +677,7 @@ out_kfree:
677 goto out; 677 goto out;
678} 678}
679 679
680static struct file_operations ip6fl_seq_fops = { 680static const struct file_operations ip6fl_seq_fops = {
681 .owner = THIS_MODULE, 681 .owner = THIS_MODULE,
682 .open = ip6fl_seq_open, 682 .open = ip6fl_seq_open,
683 .read = seq_read, 683 .read = seq_read,
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index ad0b8abcdf4b..4fdded0e545a 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * IPv6 input 2 * IPv6 input
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
@@ -48,7 +48,7 @@
48 48
49 49
50 50
51inline int ip6_rcv_finish( struct sk_buff *skb) 51inline int ip6_rcv_finish( struct sk_buff *skb)
52{ 52{
53 if (skb->dst == NULL) 53 if (skb->dst == NULL)
54 ip6_route_input(skb); 54 ip6_route_input(skb);
@@ -173,9 +173,9 @@ resubmit:
173 hash = nexthdr & (MAX_INET_PROTOS - 1); 173 hash = nexthdr & (MAX_INET_PROTOS - 1);
174 if ((ipprot = rcu_dereference(inet6_protos[hash])) != NULL) { 174 if ((ipprot = rcu_dereference(inet6_protos[hash])) != NULL) {
175 int ret; 175 int ret;
176 176
177 if (ipprot->flags & INET6_PROTO_FINAL) { 177 if (ipprot->flags & INET6_PROTO_FINAL) {
178 struct ipv6hdr *hdr; 178 struct ipv6hdr *hdr;
179 179
180 /* Free reference early: we don't need it any more, 180 /* Free reference early: we don't need it any more,
181 and it may hold ip_conntrack module loaded 181 and it may hold ip_conntrack module loaded
@@ -192,9 +192,9 @@ resubmit:
192 goto discard; 192 goto discard;
193 } 193 }
194 if (!(ipprot->flags & INET6_PROTO_NOPOLICY) && 194 if (!(ipprot->flags & INET6_PROTO_NOPOLICY) &&
195 !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 195 !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
196 goto discard; 196 goto discard;
197 197
198 ret = ipprot->handler(&skb); 198 ret = ipprot->handler(&skb);
199 if (ret > 0) 199 if (ret > 0)
200 goto resubmit; 200 goto resubmit;
@@ -205,8 +205,8 @@ resubmit:
205 if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { 205 if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
206 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INUNKNOWNPROTOS); 206 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INUNKNOWNPROTOS);
207 icmpv6_send(skb, ICMPV6_PARAMPROB, 207 icmpv6_send(skb, ICMPV6_PARAMPROB,
208 ICMPV6_UNK_NEXTHDR, nhoff, 208 ICMPV6_UNK_NEXTHDR, nhoff,
209 skb->dev); 209 skb->dev);
210 } 210 }
211 } else 211 } else
212 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDELIVERS); 212 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDELIVERS);
@@ -253,7 +253,7 @@ int ip6_mc_input(struct sk_buff *skb)
253 struct dst_entry *dst; 253 struct dst_entry *dst;
254 254
255 dst = skb->dst; 255 dst = skb->dst;
256 256
257 if (deliver) { 257 if (deliver) {
258 skb2 = skb_clone(skb, GFP_ATOMIC); 258 skb2 = skb_clone(skb, GFP_ATOMIC);
259 dst_output(skb2); 259 dst_output(skb2);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 7b7bd44fbf47..305516921aa8 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * IPv6 output functions 2 * IPv6 output functions
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: ip6_output.c,v 1.34 2002/02/01 22:01:04 davem Exp $ 8 * $Id: ip6_output.c,v 1.34 2002/02/01 22:01:04 davem Exp $
9 * 9 *
@@ -363,7 +363,7 @@ int ip6_forward(struct sk_buff *skb)
363 struct dst_entry *dst = skb->dst; 363 struct dst_entry *dst = skb->dst;
364 struct ipv6hdr *hdr = skb->nh.ipv6h; 364 struct ipv6hdr *hdr = skb->nh.ipv6h;
365 struct inet6_skb_parm *opt = IP6CB(skb); 365 struct inet6_skb_parm *opt = IP6CB(skb);
366 366
367 if (ipv6_devconf.forwarding == 0) 367 if (ipv6_devconf.forwarding == 0)
368 goto error; 368 goto error;
369 369
@@ -473,7 +473,7 @@ int ip6_forward(struct sk_buff *skb)
473 hdr = skb->nh.ipv6h; 473 hdr = skb->nh.ipv6h;
474 474
475 /* Mangling hops number delayed to point after skb COW */ 475 /* Mangling hops number delayed to point after skb COW */
476 476
477 hdr->hop_limit--; 477 hdr->hop_limit--;
478 478
479 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); 479 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
@@ -659,7 +659,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
659 frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr)); 659 frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
660 ip6_copy_metadata(frag, skb); 660 ip6_copy_metadata(frag, skb);
661 } 661 }
662 662
663 err = output(skb); 663 err = output(skb);
664 if(!err) 664 if(!err)
665 IP6_INC_STATS(ip6_dst_idev(&rt->u.dst), IPSTATS_MIB_FRAGCREATES); 665 IP6_INC_STATS(ip6_dst_idev(&rt->u.dst), IPSTATS_MIB_FRAGCREATES);
@@ -792,7 +792,7 @@ slow_path:
792fail: 792fail:
793 IP6_INC_STATS(ip6_dst_idev(skb->dst), 793 IP6_INC_STATS(ip6_dst_idev(skb->dst),
794 IPSTATS_MIB_FRAGFAILS); 794 IPSTATS_MIB_FRAGFAILS);
795 kfree_skb(skb); 795 kfree_skb(skb);
796 return err; 796 return err;
797} 797}
798 798
@@ -955,7 +955,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
955 struct frag_hdr fhdr; 955 struct frag_hdr fhdr;
956 956
957 /* specify the length of each IP datagram fragment*/ 957 /* specify the length of each IP datagram fragment*/
958 skb_shinfo(skb)->gso_size = mtu - fragheaderlen - 958 skb_shinfo(skb)->gso_size = mtu - fragheaderlen -
959 sizeof(struct frag_hdr); 959 sizeof(struct frag_hdr);
960 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; 960 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
961 ipv6_select_ident(skb, &fhdr); 961 ipv6_select_ident(skb, &fhdr);
@@ -1058,13 +1058,13 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
1058 * fragment alignment (= 8-15 octects, in total). 1058 * fragment alignment (= 8-15 octects, in total).
1059 * 1059 *
1060 * Note that we may need to "move" the data from the tail of 1060 * Note that we may need to "move" the data from the tail of
1061 * of the buffer to the new fragment when we split 1061 * of the buffer to the new fragment when we split
1062 * the message. 1062 * the message.
1063 * 1063 *
1064 * FIXME: It may be fragmented into multiple chunks 1064 * FIXME: It may be fragmented into multiple chunks
1065 * at once if non-fragmentable extension headers 1065 * at once if non-fragmentable extension headers
1066 * are too large. 1066 * are too large.
1067 * --yoshfuji 1067 * --yoshfuji
1068 */ 1068 */
1069 1069
1070 inet->cork.length += length; 1070 inet->cork.length += length;
@@ -1129,7 +1129,7 @@ alloc_new_skb:
1129 1129
1130 /* 1130 /*
1131 * We just reserve space for fragment header. 1131 * We just reserve space for fragment header.
1132 * Note: this may be overallocation if the message 1132 * Note: this may be overallocation if the message
1133 * (without MSG_MORE) fits into the MTU. 1133 * (without MSG_MORE) fits into the MTU.
1134 */ 1134 */
1135 alloclen += sizeof(struct frag_hdr); 1135 alloclen += sizeof(struct frag_hdr);
@@ -1310,7 +1310,7 @@ int ip6_push_pending_frames(struct sock *sk)
1310 ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst); 1310 ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst);
1311 1311
1312 skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); 1312 skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr));
1313 1313
1314 *(__be32*)hdr = fl->fl6_flowlabel | 1314 *(__be32*)hdr = fl->fl6_flowlabel |
1315 htonl(0x60000000 | ((int)np->cork.tclass << 20)); 1315 htonl(0x60000000 | ((int)np->cork.tclass << 20));
1316 1316
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 8d918348f5bb..367b74832986 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -3,7 +3,7 @@
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Ville Nuorvala <vnuorval@tcs.hut.fi> 6 * Ville Nuorvala <vnuorval@tcs.hut.fi>
7 * 7 *
8 * $Id$ 8 * $Id$
9 * 9 *
@@ -67,8 +67,8 @@ MODULE_LICENSE("GPL");
67#define HASH_SIZE 32 67#define HASH_SIZE 32
68 68
69#define HASH(addr) ((__force u32)((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \ 69#define HASH(addr) ((__force u32)((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
70 (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ 70 (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
71 (HASH_SIZE - 1)) 71 (HASH_SIZE - 1))
72 72
73static int ip6ip6_fb_tnl_dev_init(struct net_device *dev); 73static int ip6ip6_fb_tnl_dev_init(struct net_device *dev);
74static int ip6ip6_tnl_dev_init(struct net_device *dev); 74static int ip6ip6_tnl_dev_init(struct net_device *dev);
@@ -90,7 +90,7 @@ static inline struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t)
90{ 90{
91 struct dst_entry *dst = t->dst_cache; 91 struct dst_entry *dst = t->dst_cache;
92 92
93 if (dst && dst->obsolete && 93 if (dst && dst->obsolete &&
94 dst->ops->check(dst, t->dst_cookie) == NULL) { 94 dst->ops->check(dst, t->dst_cookie) == NULL) {
95 t->dst_cache = NULL; 95 t->dst_cache = NULL;
96 dst_release(dst); 96 dst_release(dst);
@@ -116,12 +116,12 @@ static inline void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst)
116 116
117/** 117/**
118 * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses 118 * ip6ip6_tnl_lookup - fetch tunnel matching the end-point addresses
119 * @remote: the address of the tunnel exit-point 119 * @remote: the address of the tunnel exit-point
120 * @local: the address of the tunnel entry-point 120 * @local: the address of the tunnel entry-point
121 * 121 *
122 * Return: 122 * Return:
123 * tunnel matching given end-points if found, 123 * tunnel matching given end-points if found,
124 * else fallback tunnel if its device is up, 124 * else fallback tunnel if its device is up,
125 * else %NULL 125 * else %NULL
126 **/ 126 **/
127 127
@@ -146,13 +146,13 @@ ip6ip6_tnl_lookup(struct in6_addr *remote, struct in6_addr *local)
146 146
147/** 147/**
148 * ip6ip6_bucket - get head of list matching given tunnel parameters 148 * ip6ip6_bucket - get head of list matching given tunnel parameters
149 * @p: parameters containing tunnel end-points 149 * @p: parameters containing tunnel end-points
150 * 150 *
151 * Description: 151 * Description:
152 * ip6ip6_bucket() returns the head of the list matching the 152 * ip6ip6_bucket() returns the head of the list matching the
153 * &struct in6_addr entries laddr and raddr in @p. 153 * &struct in6_addr entries laddr and raddr in @p.
154 * 154 *
155 * Return: head of IPv6 tunnel list 155 * Return: head of IPv6 tunnel list
156 **/ 156 **/
157 157
158static struct ip6_tnl ** 158static struct ip6_tnl **
@@ -213,8 +213,8 @@ ip6ip6_tnl_unlink(struct ip6_tnl *t)
213 * 213 *
214 * Description: 214 * Description:
215 * Create tunnel matching given parameters. 215 * Create tunnel matching given parameters.
216 * 216 *
217 * Return: 217 * Return:
218 * created tunnel or NULL 218 * created tunnel or NULL
219 **/ 219 **/
220 220
@@ -234,7 +234,7 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
234 if (__dev_get_by_name(name) == NULL) 234 if (__dev_get_by_name(name) == NULL)
235 break; 235 break;
236 } 236 }
237 if (i == IP6_TNL_MAX) 237 if (i == IP6_TNL_MAX)
238 goto failed; 238 goto failed;
239 } 239 }
240 dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup); 240 dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup);
@@ -258,7 +258,7 @@ failed:
258 258
259/** 259/**
260 * ip6ip6_tnl_locate - find or create tunnel matching given parameters 260 * ip6ip6_tnl_locate - find or create tunnel matching given parameters
261 * @p: tunnel parameters 261 * @p: tunnel parameters
262 * @create: != 0 if allowed to create new tunnel if no match found 262 * @create: != 0 if allowed to create new tunnel if no match found
263 * 263 *
264 * Description: 264 * Description:
@@ -289,7 +289,7 @@ static struct ip6_tnl *ip6ip6_tnl_locate(struct ip6_tnl_parm *p, int create)
289/** 289/**
290 * ip6ip6_tnl_dev_uninit - tunnel device uninitializer 290 * ip6ip6_tnl_dev_uninit - tunnel device uninitializer
291 * @dev: the device to be destroyed 291 * @dev: the device to be destroyed
292 * 292 *
293 * Description: 293 * Description:
294 * ip6ip6_tnl_dev_uninit() removes tunnel from its list 294 * ip6ip6_tnl_dev_uninit() removes tunnel from its list
295 **/ 295 **/
@@ -314,8 +314,8 @@ ip6ip6_tnl_dev_uninit(struct net_device *dev)
314 * parse_tvl_tnl_enc_lim - handle encapsulation limit option 314 * parse_tvl_tnl_enc_lim - handle encapsulation limit option
315 * @skb: received socket buffer 315 * @skb: received socket buffer
316 * 316 *
317 * Return: 317 * Return:
318 * 0 if none was found, 318 * 0 if none was found,
319 * else index to encapsulation limit 319 * else index to encapsulation limit
320 **/ 320 **/
321 321
@@ -392,8 +392,8 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
392 __u16 len; 392 __u16 len;
393 int err = -ENOENT; 393 int err = -ENOENT;
394 394
395 /* If the packet doesn't contain the original IPv6 header we are 395 /* If the packet doesn't contain the original IPv6 header we are
396 in trouble since we might need the source address for further 396 in trouble since we might need the source address for further
397 processing of the error. */ 397 processing of the error. */
398 398
399 read_lock(&ip6ip6_lock); 399 read_lock(&ip6ip6_lock);
@@ -418,7 +418,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
418 if (net_ratelimit()) 418 if (net_ratelimit())
419 printk(KERN_WARNING 419 printk(KERN_WARNING
420 "%s: Too small hop limit or " 420 "%s: Too small hop limit or "
421 "routing loop in tunnel!\n", 421 "routing loop in tunnel!\n",
422 t->parms.name); 422 t->parms.name);
423 rel_msg = 1; 423 rel_msg = 1;
424 } 424 }
@@ -502,7 +502,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
502 int ret = 0; 502 int ret = 0;
503 503
504 if (p->flags & IP6_TNL_F_CAP_RCV) { 504 if (p->flags & IP6_TNL_F_CAP_RCV) {
505 struct net_device *ldev = NULL; 505 struct net_device *ldev = NULL;
506 506
507 if (p->link) 507 if (p->link)
508 ldev = dev_get_by_index(p->link); 508 ldev = dev_get_by_index(p->link);
@@ -525,7 +525,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
525 * Return: 0 525 * Return: 0
526 **/ 526 **/
527 527
528static int 528static int
529ip6ip6_rcv(struct sk_buff *skb) 529ip6ip6_rcv(struct sk_buff *skb)
530{ 530{
531 struct ipv6hdr *ipv6h; 531 struct ipv6hdr *ipv6h;
@@ -595,13 +595,13 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit)
595/** 595/**
596 * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own 596 * ip6ip6_tnl_addr_conflict - compare packet addresses to tunnel's own
597 * @t: the outgoing tunnel device 597 * @t: the outgoing tunnel device
598 * @hdr: IPv6 header from the incoming packet 598 * @hdr: IPv6 header from the incoming packet
599 * 599 *
600 * Description: 600 * Description:
601 * Avoid trivial tunneling loop by checking that tunnel exit-point 601 * Avoid trivial tunneling loop by checking that tunnel exit-point
602 * doesn't match source of incoming packet. 602 * doesn't match source of incoming packet.
603 * 603 *
604 * Return: 604 * Return:
605 * 1 if conflict, 605 * 1 if conflict,
606 * 0 else 606 * 0 else
607 **/ 607 **/
@@ -617,7 +617,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
617 struct ip6_tnl_parm *p = &t->parms; 617 struct ip6_tnl_parm *p = &t->parms;
618 int ret = 0; 618 int ret = 0;
619 619
620 if (p->flags & IP6_TNL_F_CAP_XMIT) { 620 if (p->flags & IP6_TNL_F_CAP_XMIT) {
621 struct net_device *ldev = NULL; 621 struct net_device *ldev = NULL;
622 622
623 if (p->link) 623 if (p->link)
@@ -641,19 +641,19 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
641 return ret; 641 return ret;
642} 642}
643/** 643/**
644 * ip6ip6_tnl_xmit - encapsulate packet and send 644 * ip6ip6_tnl_xmit - encapsulate packet and send
645 * @skb: the outgoing socket buffer 645 * @skb: the outgoing socket buffer
646 * @dev: the outgoing tunnel device 646 * @dev: the outgoing tunnel device
647 * 647 *
648 * Description: 648 * Description:
649 * Build new header and do some sanity checks on the packet before sending 649 * Build new header and do some sanity checks on the packet before sending
650 * it. 650 * it.
651 * 651 *
652 * Return: 652 * Return:
653 * 0 653 * 0
654 **/ 654 **/
655 655
656static int 656static int
657ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev) 657ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
658{ 658{
659 struct ip6_tnl *t = netdev_priv(dev); 659 struct ip6_tnl *t = netdev_priv(dev);
@@ -715,7 +715,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
715 if (tdev == dev) { 715 if (tdev == dev) {
716 stats->collisions++; 716 stats->collisions++;
717 if (net_ratelimit()) 717 if (net_ratelimit())
718 printk(KERN_WARNING 718 printk(KERN_WARNING
719 "%s: Local routing loop detected!\n", 719 "%s: Local routing loop detected!\n",
720 t->parms.name); 720 t->parms.name);
721 goto tx_err_dst_release; 721 goto tx_err_dst_release;
@@ -741,11 +741,11 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
741 * Okay, now see if we can stuff it in the buffer as-is. 741 * Okay, now see if we can stuff it in the buffer as-is.
742 */ 742 */
743 max_headroom += LL_RESERVED_SPACE(tdev); 743 max_headroom += LL_RESERVED_SPACE(tdev);
744 744
745 if (skb_headroom(skb) < max_headroom || 745 if (skb_headroom(skb) < max_headroom ||
746 skb_cloned(skb) || skb_shared(skb)) { 746 skb_cloned(skb) || skb_shared(skb)) {
747 struct sk_buff *new_skb; 747 struct sk_buff *new_skb;
748 748
749 if (!(new_skb = skb_realloc_headroom(skb, max_headroom))) 749 if (!(new_skb = skb_realloc_headroom(skb, max_headroom)))
750 goto tx_err_dst_release; 750 goto tx_err_dst_release;
751 751
@@ -775,7 +775,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
775 ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst); 775 ipv6_addr_copy(&ipv6h->daddr, &fl.fl6_dst);
776 nf_reset(skb); 776 nf_reset(skb);
777 pkt_len = skb->len; 777 pkt_len = skb->len;
778 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 778 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL,
779 skb->dst->dev, dst_output); 779 skb->dst->dev, dst_output);
780 780
781 if (net_xmit_eval(err) == 0) { 781 if (net_xmit_eval(err) == 0) {
@@ -898,14 +898,14 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p)
898} 898}
899 899
900/** 900/**
901 * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace 901 * ip6ip6_tnl_ioctl - configure ipv6 tunnels from userspace
902 * @dev: virtual device associated with tunnel 902 * @dev: virtual device associated with tunnel
903 * @ifr: parameters passed from userspace 903 * @ifr: parameters passed from userspace
904 * @cmd: command to be performed 904 * @cmd: command to be performed
905 * 905 *
906 * Description: 906 * Description:
907 * ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels 907 * ip6ip6_tnl_ioctl() is used for managing IPv6 tunnels
908 * from userspace. 908 * from userspace.
909 * 909 *
910 * The possible commands are the following: 910 * The possible commands are the following:
911 * %SIOCGETTUNNEL: get tunnel parameters for device 911 * %SIOCGETTUNNEL: get tunnel parameters for device
@@ -913,7 +913,7 @@ ip6ip6_tnl_change(struct ip6_tnl *t, struct ip6_tnl_parm *p)
913 * %SIOCCHGTUNNEL: change tunnel parameters to those given 913 * %SIOCCHGTUNNEL: change tunnel parameters to those given
914 * %SIOCDELTUNNEL: delete tunnel 914 * %SIOCDELTUNNEL: delete tunnel
915 * 915 *
916 * The fallback device "ip6tnl0", created during module 916 * The fallback device "ip6tnl0", created during module
917 * initialization, can be used for creating other tunnel devices. 917 * initialization, can be used for creating other tunnel devices.
918 * 918 *
919 * Return: 919 * Return:
@@ -999,7 +999,8 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
999 break; 999 break;
1000 dev = t->dev; 1000 dev = t->dev;
1001 } 1001 }
1002 err = unregister_netdevice(dev); 1002 err = 0;
1003 unregister_netdevice(dev);
1003 break; 1004 break;
1004 default: 1005 default:
1005 err = -EINVAL; 1006 err = -EINVAL;
@@ -1008,7 +1009,7 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1008} 1009}
1009 1010
1010/** 1011/**
1011 * ip6ip6_tnl_get_stats - return the stats for tunnel device 1012 * ip6ip6_tnl_get_stats - return the stats for tunnel device
1012 * @dev: virtual device associated with tunnel 1013 * @dev: virtual device associated with tunnel
1013 * 1014 *
1014 * Return: stats for device 1015 * Return: stats for device
@@ -1101,7 +1102,7 @@ ip6ip6_tnl_dev_init(struct net_device *dev)
1101 * Return: 0 1102 * Return: 0
1102 **/ 1103 **/
1103 1104
1104static int 1105static int
1105ip6ip6_fb_tnl_dev_init(struct net_device *dev) 1106ip6ip6_fb_tnl_dev_init(struct net_device *dev)
1106{ 1107{
1107 struct ip6_tnl *t = netdev_priv(dev); 1108 struct ip6_tnl *t = netdev_priv(dev);
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 511730b67e97..5724ba9f75de 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -9,25 +9,25 @@
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22/* 22/*
23 * [Memo] 23 * [Memo]
24 * 24 *
25 * Outbound: 25 * Outbound:
26 * The compression of IP datagram MUST be done before AH/ESP processing, 26 * The compression of IP datagram MUST be done before AH/ESP processing,
27 * fragmentation, and the addition of Hop-by-Hop/Routing header. 27 * fragmentation, and the addition of Hop-by-Hop/Routing header.
28 * 28 *
29 * Inbound: 29 * Inbound:
30 * The decompression of IP datagram MUST be done after the reassembly, 30 * The decompression of IP datagram MUST be done after the reassembly,
31 * AH/ESP processing. 31 * AH/ESP processing.
32 */ 32 */
33#include <linux/module.h> 33#include <linux/module.h>
@@ -176,7 +176,7 @@ out_ok:
176} 176}
177 177
178static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 178static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
179 int type, int code, int offset, __be32 info) 179 int type, int code, int offset, __be32 info)
180{ 180{
181 __be32 spi; 181 __be32 spi;
182 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 182 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
@@ -422,7 +422,7 @@ static int ipcomp6_init_state(struct xfrm_state *x)
422 x->props.header_len = 0; 422 x->props.header_len = 0;
423 if (x->props.mode == XFRM_MODE_TUNNEL) 423 if (x->props.mode == XFRM_MODE_TUNNEL)
424 x->props.header_len += sizeof(struct ipv6hdr); 424 x->props.header_len += sizeof(struct ipv6hdr);
425 425
426 mutex_lock(&ipcomp6_resource_mutex); 426 mutex_lock(&ipcomp6_resource_mutex);
427 if (!ipcomp6_alloc_scratches()) 427 if (!ipcomp6_alloc_scratches())
428 goto error; 428 goto error;
@@ -455,7 +455,7 @@ error:
455 goto out; 455 goto out;
456} 456}
457 457
458static struct xfrm_type ipcomp6_type = 458static struct xfrm_type ipcomp6_type =
459{ 459{
460 .description = "IPCOMP6", 460 .description = "IPCOMP6",
461 .owner = THIS_MODULE, 461 .owner = THIS_MODULE,
@@ -467,7 +467,7 @@ static struct xfrm_type ipcomp6_type =
467 .hdr_offset = xfrm6_find_1stfragopt, 467 .hdr_offset = xfrm6_find_1stfragopt,
468}; 468};
469 469
470static struct inet6_protocol ipcomp6_protocol = 470static struct inet6_protocol ipcomp6_protocol =
471{ 471{
472 .handler = xfrm6_rcv, 472 .handler = xfrm6_rcv,
473 .err_handler = ipcomp6_err, 473 .err_handler = ipcomp6_err,
@@ -490,7 +490,7 @@ static int __init ipcomp6_init(void)
490 490
491static void __exit ipcomp6_fini(void) 491static void __exit ipcomp6_fini(void)
492{ 492{
493 if (inet6_del_protocol(&ipcomp6_protocol, IPPROTO_COMP) < 0) 493 if (inet6_del_protocol(&ipcomp6_protocol, IPPROTO_COMP) < 0)
494 printk(KERN_INFO "ipv6 ipcomp close: can't remove protocol\n"); 494 printk(KERN_INFO "ipv6 ipcomp close: can't remove protocol\n");
495 if (xfrm_unregister_type(&ipcomp6_type, AF_INET6) < 0) 495 if (xfrm_unregister_type(&ipcomp6_type, AF_INET6) < 0)
496 printk(KERN_INFO "ipv6 ipcomp close: can't remove xfrm type\n"); 496 printk(KERN_INFO "ipv6 ipcomp close: can't remove xfrm type\n");
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 352690e2ab82..3f1e779ea5c5 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * IPv6 BSD socket options interface 2 * IPv6 BSD socket options interface
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * Based on linux/net/ipv4/ip_sockglue.c 8 * Based on linux/net/ipv4/ip_sockglue.c
9 * 9 *
@@ -164,7 +164,7 @@ out:
164} 164}
165 165
166static struct packet_type ipv6_packet_type = { 166static struct packet_type ipv6_packet_type = {
167 .type = __constant_htons(ETH_P_IPV6), 167 .type = __constant_htons(ETH_P_IPV6),
168 .func = ipv6_rcv, 168 .func = ipv6_rcv,
169 .gso_send_check = ipv6_gso_send_check, 169 .gso_send_check = ipv6_gso_send_check,
170 .gso_segment = ipv6_gso_segment, 170 .gso_segment = ipv6_gso_segment,
@@ -320,7 +320,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
320 np->rxopt.bits.rxinfo = valbool; 320 np->rxopt.bits.rxinfo = valbool;
321 retv = 0; 321 retv = 0;
322 break; 322 break;
323 323
324 case IPV6_2292PKTINFO: 324 case IPV6_2292PKTINFO:
325 np->rxopt.bits.rxoinfo = valbool; 325 np->rxopt.bits.rxoinfo = valbool;
326 retv = 0; 326 retv = 0;
@@ -376,7 +376,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
376 np->tclass = val; 376 np->tclass = val;
377 retv = 0; 377 retv = 0;
378 break; 378 break;
379 379
380 case IPV6_RECVTCLASS: 380 case IPV6_RECVTCLASS:
381 np->rxopt.bits.rxtclass = valbool; 381 np->rxopt.bits.rxtclass = valbool;
382 retv = 0; 382 retv = 0;
@@ -893,7 +893,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
893 case IPV6_MTU: 893 case IPV6_MTU:
894 { 894 {
895 struct dst_entry *dst; 895 struct dst_entry *dst;
896 val = 0; 896 val = 0;
897 lock_sock(sk); 897 lock_sock(sk);
898 dst = sk_dst_get(sk); 898 dst = sk_dst_get(sk);
899 if (dst) { 899 if (dst) {
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 882cde4b4047..a8d6625ec782 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1,13 +1,13 @@
1/* 1/*
2 * Multicast support for IPv6 2 * Multicast support for IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: mcast.c,v 1.40 2002/02/08 03:57:19 davem Exp $ 8 * $Id: mcast.c,v 1.40 2002/02/08 03:57:19 davem Exp $
9 * 9 *
10 * Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c 10 * Based on linux/ipv4/igmp.c and linux/ipv4/ip_sockglue.c
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -644,7 +644,7 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
644 memset(&ss, 0, sizeof(ss)); 644 memset(&ss, 0, sizeof(ss));
645 psin6->sin6_family = AF_INET6; 645 psin6->sin6_family = AF_INET6;
646 psin6->sin6_addr = psl->sl_addr[i]; 646 psin6->sin6_addr = psl->sl_addr[i];
647 if (copy_to_user(&optval->gf_slist[i], &ss, sizeof(ss))) 647 if (copy_to_user(&optval->gf_slist[i], &ss, sizeof(ss)))
648 return -EFAULT; 648 return -EFAULT;
649 } 649 }
650 return 0; 650 return 0;
@@ -1168,7 +1168,7 @@ int igmp6_event_query(struct sk_buff *skb)
1168 1168
1169 /* compute payload length excluding extension headers */ 1169 /* compute payload length excluding extension headers */
1170 len = ntohs(skb->nh.ipv6h->payload_len) + sizeof(struct ipv6hdr); 1170 len = ntohs(skb->nh.ipv6h->payload_len) + sizeof(struct ipv6hdr);
1171 len -= (char *)skb->h.raw - (char *)skb->nh.ipv6h; 1171 len -= (char *)skb->h.raw - (char *)skb->nh.ipv6h;
1172 1172
1173 /* Drop queries with not link local source */ 1173 /* Drop queries with not link local source */
1174 if (!(ipv6_addr_type(&skb->nh.ipv6h->saddr)&IPV6_ADDR_LINKLOCAL)) 1174 if (!(ipv6_addr_type(&skb->nh.ipv6h->saddr)&IPV6_ADDR_LINKLOCAL))
@@ -1206,7 +1206,7 @@ int igmp6_event_query(struct sk_buff *skb)
1206 /* clear deleted report items */ 1206 /* clear deleted report items */
1207 mld_clear_delrec(idev); 1207 mld_clear_delrec(idev);
1208 } else if (len >= 28) { 1208 } else if (len >= 28) {
1209 int srcs_offset = sizeof(struct mld2_query) - 1209 int srcs_offset = sizeof(struct mld2_query) -
1210 sizeof(struct icmp6hdr); 1210 sizeof(struct icmp6hdr);
1211 if (!pskb_may_pull(skb, srcs_offset)) { 1211 if (!pskb_may_pull(skb, srcs_offset)) {
1212 in6_dev_put(idev); 1212 in6_dev_put(idev);
@@ -1230,7 +1230,7 @@ int igmp6_event_query(struct sk_buff *skb)
1230 } 1230 }
1231 /* mark sources to include, if group & source-specific */ 1231 /* mark sources to include, if group & source-specific */
1232 if (mlh2->nsrcs != 0) { 1232 if (mlh2->nsrcs != 0) {
1233 if (!pskb_may_pull(skb, srcs_offset + 1233 if (!pskb_may_pull(skb, srcs_offset +
1234 ntohs(mlh2->nsrcs) * sizeof(struct in6_addr))) { 1234 ntohs(mlh2->nsrcs) * sizeof(struct in6_addr))) {
1235 in6_dev_put(idev); 1235 in6_dev_put(idev);
1236 return -EINVAL; 1236 return -EINVAL;
@@ -1304,7 +1304,7 @@ int igmp6_event_report(struct sk_buff *skb)
1304 1304
1305 /* Drop reports with not link local source */ 1305 /* Drop reports with not link local source */
1306 addr_type = ipv6_addr_type(&skb->nh.ipv6h->saddr); 1306 addr_type = ipv6_addr_type(&skb->nh.ipv6h->saddr);
1307 if (addr_type != IPV6_ADDR_ANY && 1307 if (addr_type != IPV6_ADDR_ANY &&
1308 !(addr_type&IPV6_ADDR_LINKLOCAL)) 1308 !(addr_type&IPV6_ADDR_LINKLOCAL))
1309 return -EINVAL; 1309 return -EINVAL;
1310 1310
@@ -1413,7 +1413,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1413 1413
1414 if (ipv6_get_lladdr(dev, &addr_buf)) { 1414 if (ipv6_get_lladdr(dev, &addr_buf)) {
1415 /* <draft-ietf-magma-mld-source-05.txt>: 1415 /* <draft-ietf-magma-mld-source-05.txt>:
1416 * use unspecified address as the source address 1416 * use unspecified address as the source address
1417 * when a valid link-local address is not available. 1417 * when a valid link-local address is not available.
1418 */ 1418 */
1419 memset(&addr_buf, 0, sizeof(addr_buf)); 1419 memset(&addr_buf, 0, sizeof(addr_buf));
@@ -1454,7 +1454,7 @@ static inline int mld_dev_queue_xmit2(struct sk_buff *skb)
1454static inline int mld_dev_queue_xmit(struct sk_buff *skb) 1454static inline int mld_dev_queue_xmit(struct sk_buff *skb)
1455{ 1455{
1456 return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, skb->dev, 1456 return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, skb->dev,
1457 mld_dev_queue_xmit2); 1457 mld_dev_queue_xmit2);
1458} 1458}
1459 1459
1460static void mld_sendpack(struct sk_buff *skb) 1460static void mld_sendpack(struct sk_buff *skb)
@@ -1582,6 +1582,8 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
1582 skb = add_grhead(skb, pmc, type, &pgr); 1582 skb = add_grhead(skb, pmc, type, &pgr);
1583 first = 0; 1583 first = 0;
1584 } 1584 }
1585 if (!skb)
1586 return NULL;
1585 psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc)); 1587 psrc = (struct in6_addr *)skb_put(skb, sizeof(*psrc));
1586 *psrc = psf->sf_addr; 1588 *psrc = psf->sf_addr;
1587 scount++; stotal++; 1589 scount++; stotal++;
@@ -1752,8 +1754,8 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1752{ 1754{
1753 struct sock *sk = igmp6_socket->sk; 1755 struct sock *sk = igmp6_socket->sk;
1754 struct inet6_dev *idev; 1756 struct inet6_dev *idev;
1755 struct sk_buff *skb; 1757 struct sk_buff *skb;
1756 struct icmp6hdr *hdr; 1758 struct icmp6hdr *hdr;
1757 struct in6_addr *snd_addr; 1759 struct in6_addr *snd_addr;
1758 struct in6_addr *addrp; 1760 struct in6_addr *addrp;
1759 struct in6_addr addr_buf; 1761 struct in6_addr addr_buf;
@@ -1791,7 +1793,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1791 1793
1792 if (ipv6_get_lladdr(dev, &addr_buf)) { 1794 if (ipv6_get_lladdr(dev, &addr_buf)) {
1793 /* <draft-ietf-magma-mld-source-05.txt>: 1795 /* <draft-ietf-magma-mld-source-05.txt>:
1794 * use unspecified address as the source address 1796 * use unspecified address as the source address
1795 * when a valid link-local address is not available. 1797 * when a valid link-local address is not available.
1796 */ 1798 */
1797 memset(&addr_buf, 0, sizeof(addr_buf)); 1799 memset(&addr_buf, 0, sizeof(addr_buf));
@@ -2328,7 +2330,7 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq)
2328 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); 2330 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
2329 2331
2330 for (state->dev = dev_base, state->idev = NULL; 2332 for (state->dev = dev_base, state->idev = NULL;
2331 state->dev; 2333 state->dev;
2332 state->dev = state->dev->next) { 2334 state->dev = state->dev->next) {
2333 struct inet6_dev *idev; 2335 struct inet6_dev *idev;
2334 idev = in6_dev_get(state->dev); 2336 idev = in6_dev_get(state->dev);
@@ -2411,7 +2413,7 @@ static int igmp6_mc_seq_show(struct seq_file *seq, void *v)
2411 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); 2413 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
2412 2414
2413 seq_printf(seq, 2415 seq_printf(seq,
2414 "%-4d %-15s " NIP6_SEQFMT " %5d %08X %ld\n", 2416 "%-4d %-15s " NIP6_SEQFMT " %5d %08X %ld\n",
2415 state->dev->ifindex, state->dev->name, 2417 state->dev->ifindex, state->dev->name,
2416 NIP6(im->mca_addr), 2418 NIP6(im->mca_addr),
2417 im->mca_users, im->mca_flags, 2419 im->mca_users, im->mca_flags,
@@ -2449,7 +2451,7 @@ out_kfree:
2449 goto out; 2451 goto out;
2450} 2452}
2451 2453
2452static struct file_operations igmp6_mc_seq_fops = { 2454static const struct file_operations igmp6_mc_seq_fops = {
2453 .owner = THIS_MODULE, 2455 .owner = THIS_MODULE,
2454 .open = igmp6_mc_seq_open, 2456 .open = igmp6_mc_seq_open,
2455 .read = seq_read, 2457 .read = seq_read,
@@ -2472,7 +2474,7 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq)
2472 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq); 2474 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
2473 2475
2474 for (state->dev = dev_base, state->idev = NULL, state->im = NULL; 2476 for (state->dev = dev_base, state->idev = NULL, state->im = NULL;
2475 state->dev; 2477 state->dev;
2476 state->dev = state->dev->next) { 2478 state->dev = state->dev->next) {
2477 struct inet6_dev *idev; 2479 struct inet6_dev *idev;
2478 idev = in6_dev_get(state->dev); 2480 idev = in6_dev_get(state->dev);
@@ -2577,7 +2579,7 @@ static int igmp6_mcf_seq_show(struct seq_file *seq, void *v)
2577 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq); 2579 struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
2578 2580
2579 if (v == SEQ_START_TOKEN) { 2581 if (v == SEQ_START_TOKEN) {
2580 seq_printf(seq, 2582 seq_printf(seq,
2581 "%3s %6s " 2583 "%3s %6s "
2582 "%32s %32s %6s %6s\n", "Idx", 2584 "%32s %32s %6s %6s\n", "Idx",
2583 "Device", "Multicast Address", 2585 "Device", "Multicast Address",
@@ -2606,7 +2608,7 @@ static int igmp6_mcf_seq_open(struct inode *inode, struct file *file)
2606 struct seq_file *seq; 2608 struct seq_file *seq;
2607 int rc = -ENOMEM; 2609 int rc = -ENOMEM;
2608 struct igmp6_mcf_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL); 2610 struct igmp6_mcf_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
2609 2611
2610 if (!s) 2612 if (!s)
2611 goto out; 2613 goto out;
2612 2614
@@ -2623,7 +2625,7 @@ out_kfree:
2623 goto out; 2625 goto out;
2624} 2626}
2625 2627
2626static struct file_operations igmp6_mcf_seq_fops = { 2628static const struct file_operations igmp6_mcf_seq_fops = {
2627 .owner = THIS_MODULE, 2629 .owner = THIS_MODULE,
2628 .open = igmp6_mcf_seq_open, 2630 .open = igmp6_mcf_seq_open,
2629 .read = seq_read, 2631 .read = seq_read,
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index be7dd7db65d7..0afcabdd8ed6 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -89,7 +89,6 @@ static int mip6_mh_len(int type)
89int mip6_mh_filter(struct sock *sk, struct sk_buff *skb) 89int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
90{ 90{
91 struct ip6_mh *mh; 91 struct ip6_mh *mh;
92 int mhlen;
93 92
94 if (!pskb_may_pull(skb, (skb->h.raw - skb->data) + 8) || 93 if (!pskb_may_pull(skb, (skb->h.raw - skb->data) + 8) ||
95 !pskb_may_pull(skb, (skb->h.raw - skb->data) + ((skb->h.raw[1] + 1) << 3))) 94 !pskb_may_pull(skb, (skb->h.raw - skb->data) + ((skb->h.raw[1] + 1) << 3)))
@@ -103,31 +102,6 @@ int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
103 mip6_param_prob(skb, 0, (&mh->ip6mh_hdrlen) - skb->nh.raw); 102 mip6_param_prob(skb, 0, (&mh->ip6mh_hdrlen) - skb->nh.raw);
104 return -1; 103 return -1;
105 } 104 }
106 mhlen = (mh->ip6mh_hdrlen + 1) << 3;
107
108 if (skb->ip_summed == CHECKSUM_COMPLETE) {
109 skb->ip_summed = CHECKSUM_UNNECESSARY;
110 if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
111 &skb->nh.ipv6h->daddr,
112 mhlen, IPPROTO_MH,
113 skb->csum)) {
114 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH hw checksum failed\n");
115 skb->ip_summed = CHECKSUM_NONE;
116 }
117 }
118 if (skb->ip_summed == CHECKSUM_NONE) {
119 if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
120 &skb->nh.ipv6h->daddr,
121 mhlen, IPPROTO_MH,
122 skb_checksum(skb, 0, mhlen, 0))) {
123 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH checksum failed "
124 "[" NIP6_FMT " > " NIP6_FMT "]\n",
125 NIP6(skb->nh.ipv6h->saddr),
126 NIP6(skb->nh.ipv6h->daddr));
127 return -1;
128 }
129 skb->ip_summed = CHECKSUM_UNNECESSARY;
130 }
131 105
132 if (mh->ip6mh_proto != IPPROTO_NONE) { 106 if (mh->ip6mh_proto != IPPROTO_NONE) {
133 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n", 107 LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n",
@@ -359,7 +333,7 @@ static struct xfrm_type mip6_destopt_type =
359 .destructor = mip6_destopt_destroy, 333 .destructor = mip6_destopt_destroy,
360 .input = mip6_destopt_input, 334 .input = mip6_destopt_input,
361 .output = mip6_destopt_output, 335 .output = mip6_destopt_output,
362 .reject = mip6_destopt_reject, 336 .reject = mip6_destopt_reject,
363 .hdr_offset = mip6_destopt_offset, 337 .hdr_offset = mip6_destopt_offset,
364 .local_addr = mip6_xfrm_addr, 338 .local_addr = mip6_xfrm_addr,
365}; 339};
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 39bb658f3c44..121f31c283f8 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * Neighbour Discovery for IPv6 2 * Neighbour Discovery for IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Mike Shaver <shaver@ingenia.com> 7 * Mike Shaver <shaver@ingenia.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
@@ -427,25 +427,25 @@ static inline void ndisc_flow_init(struct flowi *fl, u8 type,
427 427
428static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, 428static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
429 struct in6_addr *daddr, struct in6_addr *solicited_addr, 429 struct in6_addr *daddr, struct in6_addr *solicited_addr,
430 int router, int solicited, int override, int inc_opt) 430 int router, int solicited, int override, int inc_opt)
431{ 431{
432 struct in6_addr tmpaddr; 432 struct in6_addr tmpaddr;
433 struct inet6_ifaddr *ifp; 433 struct inet6_ifaddr *ifp;
434 struct inet6_dev *idev; 434 struct inet6_dev *idev;
435 struct flowi fl; 435 struct flowi fl;
436 struct dst_entry* dst; 436 struct dst_entry* dst;
437 struct sock *sk = ndisc_socket->sk; 437 struct sock *sk = ndisc_socket->sk;
438 struct in6_addr *src_addr; 438 struct in6_addr *src_addr;
439 struct nd_msg *msg; 439 struct nd_msg *msg;
440 int len; 440 int len;
441 struct sk_buff *skb; 441 struct sk_buff *skb;
442 int err; 442 int err;
443 443
444 len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr); 444 len = sizeof(struct icmp6hdr) + sizeof(struct in6_addr);
445 445
446 /* for anycast or proxy, solicited_addr != src_addr */ 446 /* for anycast or proxy, solicited_addr != src_addr */
447 ifp = ipv6_get_ifaddr(solicited_addr, dev, 1); 447 ifp = ipv6_get_ifaddr(solicited_addr, dev, 1);
448 if (ifp) { 448 if (ifp) {
449 src_addr = solicited_addr; 449 src_addr = solicited_addr;
450 in6_ifa_put(ifp); 450 in6_ifa_put(ifp);
451 } else { 451 } else {
@@ -479,7 +479,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
479 479
480 if (skb == NULL) { 480 if (skb == NULL) {
481 ND_PRINTK0(KERN_ERR 481 ND_PRINTK0(KERN_ERR
482 "ICMPv6 NA: %s() failed to allocate an skb.\n", 482 "ICMPv6 NA: %s() failed to allocate an skb.\n",
483 __FUNCTION__); 483 __FUNCTION__);
484 dst_release(dst); 484 dst_release(dst);
485 return; 485 return;
@@ -491,16 +491,16 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
491 msg = (struct nd_msg *)skb_put(skb, len); 491 msg = (struct nd_msg *)skb_put(skb, len);
492 skb->h.raw = (unsigned char*)msg; 492 skb->h.raw = (unsigned char*)msg;
493 493
494 msg->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT; 494 msg->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
495 msg->icmph.icmp6_code = 0; 495 msg->icmph.icmp6_code = 0;
496 msg->icmph.icmp6_cksum = 0; 496 msg->icmph.icmp6_cksum = 0;
497 497
498 msg->icmph.icmp6_unused = 0; 498 msg->icmph.icmp6_unused = 0;
499 msg->icmph.icmp6_router = router; 499 msg->icmph.icmp6_router = router;
500 msg->icmph.icmp6_solicited = solicited; 500 msg->icmph.icmp6_solicited = solicited;
501 msg->icmph.icmp6_override = override; 501 msg->icmph.icmp6_override = override;
502 502
503 /* Set the target address. */ 503 /* Set the target address. */
504 ipv6_addr_copy(&msg->target, solicited_addr); 504 ipv6_addr_copy(&msg->target, solicited_addr);
505 505
506 if (inc_opt) 506 if (inc_opt)
@@ -508,9 +508,9 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
508 dev->addr_len, dev->type); 508 dev->addr_len, dev->type);
509 509
510 /* checksum */ 510 /* checksum */
511 msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, len, 511 msg->icmph.icmp6_cksum = csum_ipv6_magic(src_addr, daddr, len,
512 IPPROTO_ICMPV6, 512 IPPROTO_ICMPV6,
513 csum_partial((__u8 *) msg, 513 csum_partial((__u8 *) msg,
514 len, 0)); 514 len, 0));
515 515
516 skb->dst = dst; 516 skb->dst = dst;
@@ -524,20 +524,20 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
524 524
525 if (likely(idev != NULL)) 525 if (likely(idev != NULL))
526 in6_dev_put(idev); 526 in6_dev_put(idev);
527} 527}
528 528
529void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh, 529void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
530 struct in6_addr *solicit, 530 struct in6_addr *solicit,
531 struct in6_addr *daddr, struct in6_addr *saddr) 531 struct in6_addr *daddr, struct in6_addr *saddr)
532{ 532{
533 struct flowi fl; 533 struct flowi fl;
534 struct dst_entry* dst; 534 struct dst_entry* dst;
535 struct inet6_dev *idev; 535 struct inet6_dev *idev;
536 struct sock *sk = ndisc_socket->sk; 536 struct sock *sk = ndisc_socket->sk;
537 struct sk_buff *skb; 537 struct sk_buff *skb;
538 struct nd_msg *msg; 538 struct nd_msg *msg;
539 struct in6_addr addr_buf; 539 struct in6_addr addr_buf;
540 int len; 540 int len;
541 int err; 541 int err;
542 int send_llinfo; 542 int send_llinfo;
543 543
@@ -569,7 +569,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
569 1, &err); 569 1, &err);
570 if (skb == NULL) { 570 if (skb == NULL) {
571 ND_PRINTK0(KERN_ERR 571 ND_PRINTK0(KERN_ERR
572 "ICMPv6 NA: %s() failed to allocate an skb.\n", 572 "ICMPv6 NA: %s() failed to allocate an skb.\n",
573 __FUNCTION__); 573 __FUNCTION__);
574 dst_release(dst); 574 dst_release(dst);
575 return; 575 return;
@@ -594,9 +594,9 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
594 594
595 /* checksum */ 595 /* checksum */
596 msg->icmph.icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr, 596 msg->icmph.icmp6_cksum = csum_ipv6_magic(&skb->nh.ipv6h->saddr,
597 daddr, len, 597 daddr, len,
598 IPPROTO_ICMPV6, 598 IPPROTO_ICMPV6,
599 csum_partial((__u8 *) msg, 599 csum_partial((__u8 *) msg,
600 len, 0)); 600 len, 0));
601 /* send it! */ 601 /* send it! */
602 skb->dst = dst; 602 skb->dst = dst;
@@ -619,10 +619,10 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
619 struct dst_entry* dst; 619 struct dst_entry* dst;
620 struct inet6_dev *idev; 620 struct inet6_dev *idev;
621 struct sock *sk = ndisc_socket->sk; 621 struct sock *sk = ndisc_socket->sk;
622 struct sk_buff *skb; 622 struct sk_buff *skb;
623 struct icmp6hdr *hdr; 623 struct icmp6hdr *hdr;
624 __u8 * opt; 624 __u8 * opt;
625 int len; 625 int len;
626 int err; 626 int err;
627 627
628 ndisc_flow_init(&fl, NDISC_ROUTER_SOLICITATION, saddr, daddr, 628 ndisc_flow_init(&fl, NDISC_ROUTER_SOLICITATION, saddr, daddr,
@@ -640,13 +640,13 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
640 if (dev->addr_len) 640 if (dev->addr_len)
641 len += ndisc_opt_addr_space(dev); 641 len += ndisc_opt_addr_space(dev);
642 642
643 skb = sock_alloc_send_skb(sk, 643 skb = sock_alloc_send_skb(sk,
644 (MAX_HEADER + sizeof(struct ipv6hdr) + 644 (MAX_HEADER + sizeof(struct ipv6hdr) +
645 len + LL_RESERVED_SPACE(dev)), 645 len + LL_RESERVED_SPACE(dev)),
646 1, &err); 646 1, &err);
647 if (skb == NULL) { 647 if (skb == NULL) {
648 ND_PRINTK0(KERN_ERR 648 ND_PRINTK0(KERN_ERR
649 "ICMPv6 RS: %s() failed to allocate an skb.\n", 649 "ICMPv6 RS: %s() failed to allocate an skb.\n",
650 __FUNCTION__); 650 __FUNCTION__);
651 dst_release(dst); 651 dst_release(dst);
652 return; 652 return;
@@ -655,12 +655,12 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
655 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 655 skb_reserve(skb, LL_RESERVED_SPACE(dev));
656 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len); 656 ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
657 657
658 hdr = (struct icmp6hdr *)skb_put(skb, len); 658 hdr = (struct icmp6hdr *)skb_put(skb, len);
659 skb->h.raw = (unsigned char*)hdr; 659 skb->h.raw = (unsigned char*)hdr;
660 hdr->icmp6_type = NDISC_ROUTER_SOLICITATION; 660 hdr->icmp6_type = NDISC_ROUTER_SOLICITATION;
661 hdr->icmp6_code = 0; 661 hdr->icmp6_code = 0;
662 hdr->icmp6_cksum = 0; 662 hdr->icmp6_cksum = 0;
663 hdr->icmp6_unused = 0; 663 hdr->icmp6_unused = 0;
664 664
665 opt = (u8*) (hdr + 1); 665 opt = (u8*) (hdr + 1);
666 666
@@ -686,7 +686,7 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
686 if (likely(idev != NULL)) 686 if (likely(idev != NULL))
687 in6_dev_put(idev); 687 in6_dev_put(idev);
688} 688}
689 689
690 690
691static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb) 691static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
692{ 692{
@@ -748,7 +748,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
748 int is_router; 748 int is_router;
749 749
750 if (ipv6_addr_is_multicast(&msg->target)) { 750 if (ipv6_addr_is_multicast(&msg->target)) {
751 ND_PRINTK2(KERN_WARNING 751 ND_PRINTK2(KERN_WARNING
752 "ICMPv6 NS: multicast target address"); 752 "ICMPv6 NS: multicast target address");
753 return; 753 return;
754 } 754 }
@@ -768,7 +768,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
768 } 768 }
769 769
770 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) { 770 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
771 ND_PRINTK2(KERN_WARNING 771 ND_PRINTK2(KERN_WARNING
772 "ICMPv6 NS: invalid ND options\n"); 772 "ICMPv6 NS: invalid ND options\n");
773 return; 773 return;
774 } 774 }
@@ -782,12 +782,12 @@ static void ndisc_recv_ns(struct sk_buff *skb)
782 } 782 }
783 783
784 /* RFC2461 7.1.1: 784 /* RFC2461 7.1.1:
785 * If the IP source address is the unspecified address, 785 * If the IP source address is the unspecified address,
786 * there MUST NOT be source link-layer address option 786 * there MUST NOT be source link-layer address option
787 * in the message. 787 * in the message.
788 */ 788 */
789 if (dad) { 789 if (dad) {
790 ND_PRINTK2(KERN_WARNING 790 ND_PRINTK2(KERN_WARNING
791 "ICMPv6 NS: bad DAD packet (link-layer address option)\n"); 791 "ICMPv6 NS: bad DAD packet (link-layer address option)\n");
792 return; 792 return;
793 } 793 }
@@ -816,7 +816,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
816 goto out; 816 goto out;
817 } 817 }
818 } 818 }
819 addrconf_dad_failure(ifp); 819 addrconf_dad_failure(ifp);
820 return; 820 return;
821 } 821 }
822 822
@@ -829,7 +829,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
829 } 829 }
830 830
831 if (ipv6_chk_acast_addr(dev, &msg->target) || 831 if (ipv6_chk_acast_addr(dev, &msg->target) ||
832 (idev->cnf.forwarding && 832 (idev->cnf.forwarding &&
833 (ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) && 833 (ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) &&
834 (pneigh = pneigh_lookup(&nd_tbl, 834 (pneigh = pneigh_lookup(&nd_tbl,
835 &msg->target, dev, 0)) != NULL)) { 835 &msg->target, dev, 0)) != NULL)) {
@@ -839,8 +839,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
839 idev->nd_parms->proxy_delay != 0) { 839 idev->nd_parms->proxy_delay != 0) {
840 /* 840 /*
841 * for anycast or proxy, 841 * for anycast or proxy,
842 * sender should delay its response 842 * sender should delay its response
843 * by a random time between 0 and 843 * by a random time between 0 and
844 * MAX_ANYCAST_DELAY_TIME seconds. 844 * MAX_ANYCAST_DELAY_TIME seconds.
845 * (RFC2461) -- yoshfuji 845 * (RFC2461) -- yoshfuji
846 */ 846 */
@@ -869,14 +869,14 @@ static void ndisc_recv_ns(struct sk_buff *skb)
869 else 869 else
870 NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast); 870 NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
871 871
872 /* 872 /*
873 * update / create cache entry 873 * update / create cache entry
874 * for the source address 874 * for the source address
875 */ 875 */
876 neigh = __neigh_lookup(&nd_tbl, saddr, dev, 876 neigh = __neigh_lookup(&nd_tbl, saddr, dev,
877 !inc || lladdr || !dev->addr_len); 877 !inc || lladdr || !dev->addr_len);
878 if (neigh) 878 if (neigh)
879 neigh_update(neigh, lladdr, NUD_STALE, 879 neigh_update(neigh, lladdr, NUD_STALE,
880 NEIGH_UPDATE_F_WEAK_OVERRIDE| 880 NEIGH_UPDATE_F_WEAK_OVERRIDE|
881 NEIGH_UPDATE_F_OVERRIDE); 881 NEIGH_UPDATE_F_OVERRIDE);
882 if (neigh || !dev->hard_header) { 882 if (neigh || !dev->hard_header) {
@@ -926,7 +926,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
926 "ICMPv6 NA: solicited NA is multicasted.\n"); 926 "ICMPv6 NA: solicited NA is multicasted.\n");
927 return; 927 return;
928 } 928 }
929 929
930 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) { 930 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
931 ND_PRINTK2(KERN_WARNING 931 ND_PRINTK2(KERN_WARNING
932 "ICMPv6 NS: invalid ND option\n"); 932 "ICMPv6 NS: invalid ND option\n");
@@ -1057,7 +1057,7 @@ out:
1057 1057
1058static void ndisc_router_discovery(struct sk_buff *skb) 1058static void ndisc_router_discovery(struct sk_buff *skb)
1059{ 1059{
1060 struct ra_msg *ra_msg = (struct ra_msg *) skb->h.raw; 1060 struct ra_msg *ra_msg = (struct ra_msg *) skb->h.raw;
1061 struct neighbour *neigh = NULL; 1061 struct neighbour *neigh = NULL;
1062 struct inet6_dev *in6_dev; 1062 struct inet6_dev *in6_dev;
1063 struct rt6_info *rt = NULL; 1063 struct rt6_info *rt = NULL;
@@ -1076,7 +1076,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1076 return; 1076 return;
1077 } 1077 }
1078 if (optlen < 0) { 1078 if (optlen < 0) {
1079 ND_PRINTK2(KERN_WARNING 1079 ND_PRINTK2(KERN_WARNING
1080 "ICMPv6 RA: packet too short\n"); 1080 "ICMPv6 RA: packet too short\n");
1081 return; 1081 return;
1082 } 1082 }
@@ -1286,7 +1286,7 @@ skip_defrtr:
1286 rt6_mtu_change(skb->dev, mtu); 1286 rt6_mtu_change(skb->dev, mtu);
1287 } 1287 }
1288 } 1288 }
1289 1289
1290 if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) { 1290 if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
1291 ND_PRINTK2(KERN_WARNING 1291 ND_PRINTK2(KERN_WARNING
1292 "ICMPv6 RA: invalid RA options"); 1292 "ICMPv6 RA: invalid RA options");
@@ -1339,7 +1339,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1339 if (ipv6_addr_equal(dest, target)) { 1339 if (ipv6_addr_equal(dest, target)) {
1340 on_link = 1; 1340 on_link = 1;
1341 } else if (!(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) { 1341 } else if (!(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
1342 ND_PRINTK2(KERN_WARNING 1342 ND_PRINTK2(KERN_WARNING
1343 "ICMPv6 Redirect: target address is not link-local.\n"); 1343 "ICMPv6 Redirect: target address is not link-local.\n");
1344 return; 1344 return;
1345 } 1345 }
@@ -1352,11 +1352,11 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1352 return; 1352 return;
1353 } 1353 }
1354 1354
1355 /* RFC2461 8.1: 1355 /* RFC2461 8.1:
1356 * The IP source address of the Redirect MUST be the same as the current 1356 * The IP source address of the Redirect MUST be the same as the current
1357 * first-hop router for the specified ICMP Destination Address. 1357 * first-hop router for the specified ICMP Destination Address.
1358 */ 1358 */
1359 1359
1360 if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) { 1360 if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) {
1361 ND_PRINTK2(KERN_WARNING 1361 ND_PRINTK2(KERN_WARNING
1362 "ICMPv6 Redirect: invalid ND options\n"); 1362 "ICMPv6 Redirect: invalid ND options\n");
@@ -1410,8 +1410,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1410 ND_PRINTK2(KERN_WARNING 1410 ND_PRINTK2(KERN_WARNING
1411 "ICMPv6 Redirect: no link-local address on %s\n", 1411 "ICMPv6 Redirect: no link-local address on %s\n",
1412 dev->name); 1412 dev->name);
1413 return; 1413 return;
1414 } 1414 }
1415 1415
1416 if (!ipv6_addr_equal(&skb->nh.ipv6h->daddr, target) && 1416 if (!ipv6_addr_equal(&skb->nh.ipv6h->daddr, target) &&
1417 !(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) { 1417 !(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
@@ -1507,7 +1507,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1507 * build redirect option and copy skb over to the new packet. 1507 * build redirect option and copy skb over to the new packet.
1508 */ 1508 */
1509 1509
1510 memset(opt, 0, 8); 1510 memset(opt, 0, 8);
1511 *(opt++) = ND_OPT_REDIRECT_HDR; 1511 *(opt++) = ND_OPT_REDIRECT_HDR;
1512 *(opt++) = (rd_len >> 3); 1512 *(opt++) = (rd_len >> 3);
1513 opt += 6; 1513 opt += 6;
@@ -1556,7 +1556,7 @@ int ndisc_rcv(struct sk_buff *skb)
1556 } 1556 }
1557 1557
1558 if (msg->icmph.icmp6_code != 0) { 1558 if (msg->icmph.icmp6_code != 0) {
1559 ND_PRINTK2(KERN_WARNING 1559 ND_PRINTK2(KERN_WARNING
1560 "ICMPv6 NDISC: invalid ICMPv6 code: %d\n", 1560 "ICMPv6 NDISC: invalid ICMPv6 code: %d\n",
1561 msg->icmph.icmp6_code); 1561 msg->icmph.icmp6_code);
1562 return 0; 1562 return 0;
@@ -1717,12 +1717,12 @@ int __init ndisc_init(struct net_proto_family *ops)
1717{ 1717{
1718 struct ipv6_pinfo *np; 1718 struct ipv6_pinfo *np;
1719 struct sock *sk; 1719 struct sock *sk;
1720 int err; 1720 int err;
1721 1721
1722 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &ndisc_socket); 1722 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &ndisc_socket);
1723 if (err < 0) { 1723 if (err < 0) {
1724 ND_PRINTK0(KERN_ERR 1724 ND_PRINTK0(KERN_ERR
1725 "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n", 1725 "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n",
1726 err); 1726 err);
1727 ndisc_socket = NULL; /* For safety. */ 1727 ndisc_socket = NULL; /* For safety. */
1728 return err; 1728 return err;
@@ -1736,14 +1736,14 @@ int __init ndisc_init(struct net_proto_family *ops)
1736 np->mc_loop = 0; 1736 np->mc_loop = 0;
1737 sk->sk_prot->unhash(sk); 1737 sk->sk_prot->unhash(sk);
1738 1738
1739 /* 1739 /*
1740 * Initialize the neighbour table 1740 * Initialize the neighbour table
1741 */ 1741 */
1742 1742
1743 neigh_table_init(&nd_tbl); 1743 neigh_table_init(&nd_tbl);
1744 1744
1745#ifdef CONFIG_SYSCTL 1745#ifdef CONFIG_SYSCTL
1746 neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH, 1746 neigh_sysctl_register(NULL, &nd_tbl.parms, NET_IPV6, NET_IPV6_NEIGH,
1747 "ipv6", 1747 "ipv6",
1748 &ndisc_ifinfo_sysctl_change, 1748 &ndisc_ifinfo_sysctl_change,
1749 &ndisc_ifinfo_sysctl_strategy); 1749 &ndisc_ifinfo_sysctl_strategy);
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index f6294e5bcb31..0b2d265e7da7 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -91,7 +91,7 @@ __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
91 if (hook != NF_IP6_PRE_ROUTING && hook != NF_IP6_LOCAL_IN) 91 if (hook != NF_IP6_PRE_ROUTING && hook != NF_IP6_LOCAL_IN)
92 break; 92 break;
93 if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, 93 if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
94 skb->len - dataoff, protocol, 94 skb->len - dataoff, protocol,
95 csum_sub(skb->csum, 95 csum_sub(skb->csum,
96 skb_checksum(skb, 0, 96 skb_checksum(skb, 0,
97 dataoff, 0)))) { 97 dataoff, 0)))) {
@@ -106,7 +106,7 @@ __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
106 protocol, 106 protocol,
107 csum_sub(0, 107 csum_sub(0,
108 skb_checksum(skb, 0, 108 skb_checksum(skb, 0,
109 dataoff, 0)))); 109 dataoff, 0))));
110 csum = __skb_checksum_complete(skb); 110 csum = __skb_checksum_complete(skb);
111 } 111 }
112 return csum; 112 return csum;
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
index adcd6131df2a..da07e9a88ee9 100644
--- a/net/ipv6/netfilter/Kconfig
+++ b/net/ipv6/netfilter/Kconfig
@@ -42,7 +42,8 @@ config IP6_NF_QUEUE
42 42
43config IP6_NF_IPTABLES 43config IP6_NF_IPTABLES
44 tristate "IP6 tables support (required for filtering)" 44 tristate "IP6 tables support (required for filtering)"
45 depends on INET && IPV6 && EXPERIMENTAL && NETFILTER_XTABLES 45 depends on INET && IPV6 && EXPERIMENTAL
46 select NETFILTER_XTABLES
46 help 47 help
47 ip6tables is a general, extensible packet identification framework. 48 ip6tables is a general, extensible packet identification framework.
48 Currently only the packet filtering and packet mangling subsystem 49 Currently only the packet filtering and packet mangling subsystem
@@ -114,6 +115,14 @@ config IP6_NF_MATCH_AH
114 115
115 To compile it as a module, choose M here. If unsure, say N. 116 To compile it as a module, choose M here. If unsure, say N.
116 117
118config IP6_NF_MATCH_MH
119 tristate "MH match support"
120 depends on IP6_NF_IPTABLES
121 help
122 This module allows one to match MH packets.
123
124 To compile it as a module, choose M here. If unsure, say N.
125
117config IP6_NF_MATCH_EUI64 126config IP6_NF_MATCH_EUI64
118 tristate "EUI64 address check" 127 tristate "EUI64 address check"
119 depends on IP6_NF_IPTABLES 128 depends on IP6_NF_IPTABLES
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile
index ac1dfebde175..4513eab77397 100644
--- a/net/ipv6/netfilter/Makefile
+++ b/net/ipv6/netfilter/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
19obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o 19obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
20obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o 20obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
21obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o 21obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o
22obj-$(CONFIG_IP6_NF_MATCH_MH) += ip6t_mh.o
22 23
23# objects for l3 independent conntrack 24# objects for l3 independent conntrack
24nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o 25nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index d4d9f182441a..58847d3b61e5 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -95,7 +95,7 @@ __ipq_find_entry(ipq_cmpfn cmpfn, unsigned long data)
95 95
96 list_for_each_prev(p, &queue_list) { 96 list_for_each_prev(p, &queue_list) {
97 struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p; 97 struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p;
98 98
99 if (!cmpfn || cmpfn(entry, data)) 99 if (!cmpfn || cmpfn(entry, data))
100 return entry; 100 return entry;
101 } 101 }
@@ -127,7 +127,7 @@ static inline void
127__ipq_flush(int verdict) 127__ipq_flush(int verdict)
128{ 128{
129 struct ipq_queue_entry *entry; 129 struct ipq_queue_entry *entry;
130 130
131 while ((entry = __ipq_find_dequeue_entry(NULL, 0))) 131 while ((entry = __ipq_find_dequeue_entry(NULL, 0)))
132 ipq_issue_verdict(entry, verdict); 132 ipq_issue_verdict(entry, verdict);
133} 133}
@@ -136,21 +136,21 @@ static inline int
136__ipq_set_mode(unsigned char mode, unsigned int range) 136__ipq_set_mode(unsigned char mode, unsigned int range)
137{ 137{
138 int status = 0; 138 int status = 0;
139 139
140 switch(mode) { 140 switch(mode) {
141 case IPQ_COPY_NONE: 141 case IPQ_COPY_NONE:
142 case IPQ_COPY_META: 142 case IPQ_COPY_META:
143 copy_mode = mode; 143 copy_mode = mode;
144 copy_range = 0; 144 copy_range = 0;
145 break; 145 break;
146 146
147 case IPQ_COPY_PACKET: 147 case IPQ_COPY_PACKET:
148 copy_mode = mode; 148 copy_mode = mode;
149 copy_range = range; 149 copy_range = range;
150 if (copy_range > 0xFFFF) 150 if (copy_range > 0xFFFF)
151 copy_range = 0xFFFF; 151 copy_range = 0xFFFF;
152 break; 152 break;
153 153
154 default: 154 default:
155 status = -EINVAL; 155 status = -EINVAL;
156 156
@@ -171,7 +171,7 @@ static struct ipq_queue_entry *
171ipq_find_dequeue_entry(ipq_cmpfn cmpfn, unsigned long data) 171ipq_find_dequeue_entry(ipq_cmpfn cmpfn, unsigned long data)
172{ 172{
173 struct ipq_queue_entry *entry; 173 struct ipq_queue_entry *entry;
174 174
175 write_lock_bh(&queue_lock); 175 write_lock_bh(&queue_lock);
176 entry = __ipq_find_dequeue_entry(cmpfn, data); 176 entry = __ipq_find_dequeue_entry(cmpfn, data);
177 write_unlock_bh(&queue_lock); 177 write_unlock_bh(&queue_lock);
@@ -197,14 +197,14 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
197 struct nlmsghdr *nlh; 197 struct nlmsghdr *nlh;
198 198
199 read_lock_bh(&queue_lock); 199 read_lock_bh(&queue_lock);
200 200
201 switch (copy_mode) { 201 switch (copy_mode) {
202 case IPQ_COPY_META: 202 case IPQ_COPY_META:
203 case IPQ_COPY_NONE: 203 case IPQ_COPY_NONE:
204 size = NLMSG_SPACE(sizeof(*pmsg)); 204 size = NLMSG_SPACE(sizeof(*pmsg));
205 data_len = 0; 205 data_len = 0;
206 break; 206 break;
207 207
208 case IPQ_COPY_PACKET: 208 case IPQ_COPY_PACKET:
209 if ((entry->skb->ip_summed == CHECKSUM_PARTIAL || 209 if ((entry->skb->ip_summed == CHECKSUM_PARTIAL ||
210 entry->skb->ip_summed == CHECKSUM_COMPLETE) && 210 entry->skb->ip_summed == CHECKSUM_COMPLETE) &&
@@ -216,10 +216,10 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
216 data_len = entry->skb->len; 216 data_len = entry->skb->len;
217 else 217 else
218 data_len = copy_range; 218 data_len = copy_range;
219 219
220 size = NLMSG_SPACE(sizeof(*pmsg) + data_len); 220 size = NLMSG_SPACE(sizeof(*pmsg) + data_len);
221 break; 221 break;
222 222
223 default: 223 default:
224 *errp = -EINVAL; 224 *errp = -EINVAL;
225 read_unlock_bh(&queue_lock); 225 read_unlock_bh(&queue_lock);
@@ -231,7 +231,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
231 skb = alloc_skb(size, GFP_ATOMIC); 231 skb = alloc_skb(size, GFP_ATOMIC);
232 if (!skb) 232 if (!skb)
233 goto nlmsg_failure; 233 goto nlmsg_failure;
234 234
235 old_tail= skb->tail; 235 old_tail= skb->tail;
236 nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh)); 236 nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));
237 pmsg = NLMSG_DATA(nlh); 237 pmsg = NLMSG_DATA(nlh);
@@ -244,29 +244,29 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
244 pmsg->mark = entry->skb->mark; 244 pmsg->mark = entry->skb->mark;
245 pmsg->hook = entry->info->hook; 245 pmsg->hook = entry->info->hook;
246 pmsg->hw_protocol = entry->skb->protocol; 246 pmsg->hw_protocol = entry->skb->protocol;
247 247
248 if (entry->info->indev) 248 if (entry->info->indev)
249 strcpy(pmsg->indev_name, entry->info->indev->name); 249 strcpy(pmsg->indev_name, entry->info->indev->name);
250 else 250 else
251 pmsg->indev_name[0] = '\0'; 251 pmsg->indev_name[0] = '\0';
252 252
253 if (entry->info->outdev) 253 if (entry->info->outdev)
254 strcpy(pmsg->outdev_name, entry->info->outdev->name); 254 strcpy(pmsg->outdev_name, entry->info->outdev->name);
255 else 255 else
256 pmsg->outdev_name[0] = '\0'; 256 pmsg->outdev_name[0] = '\0';
257 257
258 if (entry->info->indev && entry->skb->dev) { 258 if (entry->info->indev && entry->skb->dev) {
259 pmsg->hw_type = entry->skb->dev->type; 259 pmsg->hw_type = entry->skb->dev->type;
260 if (entry->skb->dev->hard_header_parse) 260 if (entry->skb->dev->hard_header_parse)
261 pmsg->hw_addrlen = 261 pmsg->hw_addrlen =
262 entry->skb->dev->hard_header_parse(entry->skb, 262 entry->skb->dev->hard_header_parse(entry->skb,
263 pmsg->hw_addr); 263 pmsg->hw_addr);
264 } 264 }
265 265
266 if (data_len) 266 if (data_len)
267 if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len)) 267 if (skb_copy_bits(entry->skb, 0, pmsg->payload, data_len))
268 BUG(); 268 BUG();
269 269
270 nlh->nlmsg_len = skb->tail - old_tail; 270 nlh->nlmsg_len = skb->tail - old_tail;
271 return skb; 271 return skb;
272 272
@@ -279,7 +279,7 @@ nlmsg_failure:
279} 279}
280 280
281static int 281static int
282ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info, 282ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
283 unsigned int queuenum, void *data) 283 unsigned int queuenum, void *data)
284{ 284{
285 int status = -EINVAL; 285 int status = -EINVAL;
@@ -301,37 +301,37 @@ ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
301 nskb = ipq_build_packet_message(entry, &status); 301 nskb = ipq_build_packet_message(entry, &status);
302 if (nskb == NULL) 302 if (nskb == NULL)
303 goto err_out_free; 303 goto err_out_free;
304 304
305 write_lock_bh(&queue_lock); 305 write_lock_bh(&queue_lock);
306 306
307 if (!peer_pid) 307 if (!peer_pid)
308 goto err_out_free_nskb; 308 goto err_out_free_nskb;
309 309
310 if (queue_total >= queue_maxlen) { 310 if (queue_total >= queue_maxlen) {
311 queue_dropped++; 311 queue_dropped++;
312 status = -ENOSPC; 312 status = -ENOSPC;
313 if (net_ratelimit()) 313 if (net_ratelimit())
314 printk (KERN_WARNING "ip6_queue: fill at %d entries, " 314 printk (KERN_WARNING "ip6_queue: fill at %d entries, "
315 "dropping packet(s). Dropped: %d\n", queue_total, 315 "dropping packet(s). Dropped: %d\n", queue_total,
316 queue_dropped); 316 queue_dropped);
317 goto err_out_free_nskb; 317 goto err_out_free_nskb;
318 } 318 }
319 319
320 /* netlink_unicast will either free the nskb or attach it to a socket */ 320 /* netlink_unicast will either free the nskb or attach it to a socket */
321 status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT); 321 status = netlink_unicast(ipqnl, nskb, peer_pid, MSG_DONTWAIT);
322 if (status < 0) { 322 if (status < 0) {
323 queue_user_dropped++; 323 queue_user_dropped++;
324 goto err_out_unlock; 324 goto err_out_unlock;
325 } 325 }
326 326
327 __ipq_enqueue_entry(entry); 327 __ipq_enqueue_entry(entry);
328 328
329 write_unlock_bh(&queue_lock); 329 write_unlock_bh(&queue_lock);
330 return status; 330 return status;
331 331
332err_out_free_nskb: 332err_out_free_nskb:
333 kfree_skb(nskb); 333 kfree_skb(nskb);
334 334
335err_out_unlock: 335err_out_unlock:
336 write_unlock_bh(&queue_lock); 336 write_unlock_bh(&queue_lock);
337 337
@@ -357,11 +357,11 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)
357 return -EINVAL; 357 return -EINVAL;
358 if (diff > skb_tailroom(e->skb)) { 358 if (diff > skb_tailroom(e->skb)) {
359 struct sk_buff *newskb; 359 struct sk_buff *newskb;
360 360
361 newskb = skb_copy_expand(e->skb, 361 newskb = skb_copy_expand(e->skb,
362 skb_headroom(e->skb), 362 skb_headroom(e->skb),
363 diff, 363 diff,
364 GFP_ATOMIC); 364 GFP_ATOMIC);
365 if (newskb == NULL) { 365 if (newskb == NULL) {
366 printk(KERN_WARNING "ip6_queue: OOM " 366 printk(KERN_WARNING "ip6_queue: OOM "
367 "in mangle, dropping packet\n"); 367 "in mangle, dropping packet\n");
@@ -401,11 +401,11 @@ ipq_set_verdict(struct ipq_verdict_msg *vmsg, unsigned int len)
401 return -ENOENT; 401 return -ENOENT;
402 else { 402 else {
403 int verdict = vmsg->value; 403 int verdict = vmsg->value;
404 404
405 if (vmsg->data_len && vmsg->data_len == len) 405 if (vmsg->data_len && vmsg->data_len == len)
406 if (ipq_mangle_ipv6(vmsg, entry) < 0) 406 if (ipq_mangle_ipv6(vmsg, entry) < 0)
407 verdict = NF_DROP; 407 verdict = NF_DROP;
408 408
409 ipq_issue_verdict(entry, verdict); 409 ipq_issue_verdict(entry, verdict);
410 return 0; 410 return 0;
411 } 411 }
@@ -424,7 +424,7 @@ ipq_set_mode(unsigned char mode, unsigned int range)
424 424
425static int 425static int
426ipq_receive_peer(struct ipq_peer_msg *pmsg, 426ipq_receive_peer(struct ipq_peer_msg *pmsg,
427 unsigned char type, unsigned int len) 427 unsigned char type, unsigned int len)
428{ 428{
429 int status = 0; 429 int status = 0;
430 430
@@ -434,15 +434,15 @@ ipq_receive_peer(struct ipq_peer_msg *pmsg,
434 switch (type) { 434 switch (type) {
435 case IPQM_MODE: 435 case IPQM_MODE:
436 status = ipq_set_mode(pmsg->msg.mode.value, 436 status = ipq_set_mode(pmsg->msg.mode.value,
437 pmsg->msg.mode.range); 437 pmsg->msg.mode.range);
438 break; 438 break;
439 439
440 case IPQM_VERDICT: 440 case IPQM_VERDICT:
441 if (pmsg->msg.verdict.value > NF_MAX_VERDICT) 441 if (pmsg->msg.verdict.value > NF_MAX_VERDICT)
442 status = -EINVAL; 442 status = -EINVAL;
443 else 443 else
444 status = ipq_set_verdict(&pmsg->msg.verdict, 444 status = ipq_set_verdict(&pmsg->msg.verdict,
445 len - sizeof(*pmsg)); 445 len - sizeof(*pmsg));
446 break; 446 break;
447 default: 447 default:
448 status = -EINVAL; 448 status = -EINVAL;
@@ -456,7 +456,7 @@ dev_cmp(struct ipq_queue_entry *entry, unsigned long ifindex)
456 if (entry->info->indev) 456 if (entry->info->indev)
457 if (entry->info->indev->ifindex == ifindex) 457 if (entry->info->indev->ifindex == ifindex)
458 return 1; 458 return 1;
459 459
460 if (entry->info->outdev) 460 if (entry->info->outdev)
461 if (entry->info->outdev->ifindex == ifindex) 461 if (entry->info->outdev->ifindex == ifindex)
462 return 1; 462 return 1;
@@ -468,7 +468,7 @@ static void
468ipq_dev_drop(int ifindex) 468ipq_dev_drop(int ifindex)
469{ 469{
470 struct ipq_queue_entry *entry; 470 struct ipq_queue_entry *entry;
471 471
472 while ((entry = ipq_find_dequeue_entry(dev_cmp, ifindex)) != NULL) 472 while ((entry = ipq_find_dequeue_entry(dev_cmp, ifindex)) != NULL)
473 ipq_issue_verdict(entry, NF_DROP); 473 ipq_issue_verdict(entry, NF_DROP);
474} 474}
@@ -492,25 +492,25 @@ ipq_rcv_skb(struct sk_buff *skb)
492 492
493 pid = nlh->nlmsg_pid; 493 pid = nlh->nlmsg_pid;
494 flags = nlh->nlmsg_flags; 494 flags = nlh->nlmsg_flags;
495 495
496 if(pid <= 0 || !(flags & NLM_F_REQUEST) || flags & NLM_F_MULTI) 496 if(pid <= 0 || !(flags & NLM_F_REQUEST) || flags & NLM_F_MULTI)
497 RCV_SKB_FAIL(-EINVAL); 497 RCV_SKB_FAIL(-EINVAL);
498 498
499 if (flags & MSG_TRUNC) 499 if (flags & MSG_TRUNC)
500 RCV_SKB_FAIL(-ECOMM); 500 RCV_SKB_FAIL(-ECOMM);
501 501
502 type = nlh->nlmsg_type; 502 type = nlh->nlmsg_type;
503 if (type < NLMSG_NOOP || type >= IPQM_MAX) 503 if (type < NLMSG_NOOP || type >= IPQM_MAX)
504 RCV_SKB_FAIL(-EINVAL); 504 RCV_SKB_FAIL(-EINVAL);
505 505
506 if (type <= IPQM_BASE) 506 if (type <= IPQM_BASE)
507 return; 507 return;
508 508
509 if (security_netlink_recv(skb, CAP_NET_ADMIN)) 509 if (security_netlink_recv(skb, CAP_NET_ADMIN))
510 RCV_SKB_FAIL(-EPERM); 510 RCV_SKB_FAIL(-EPERM);
511 511
512 write_lock_bh(&queue_lock); 512 write_lock_bh(&queue_lock);
513 513
514 if (peer_pid) { 514 if (peer_pid) {
515 if (peer_pid != pid) { 515 if (peer_pid != pid) {
516 write_unlock_bh(&queue_lock); 516 write_unlock_bh(&queue_lock);
@@ -520,17 +520,17 @@ ipq_rcv_skb(struct sk_buff *skb)
520 net_enable_timestamp(); 520 net_enable_timestamp();
521 peer_pid = pid; 521 peer_pid = pid;
522 } 522 }
523 523
524 write_unlock_bh(&queue_lock); 524 write_unlock_bh(&queue_lock);
525 525
526 status = ipq_receive_peer(NLMSG_DATA(nlh), type, 526 status = ipq_receive_peer(NLMSG_DATA(nlh), type,
527 nlmsglen - NLMSG_LENGTH(0)); 527 nlmsglen - NLMSG_LENGTH(0));
528 if (status < 0) 528 if (status < 0)
529 RCV_SKB_FAIL(status); 529 RCV_SKB_FAIL(status);
530 530
531 if (flags & NLM_F_ACK) 531 if (flags & NLM_F_ACK)
532 netlink_ack(skb, nlh, 0); 532 netlink_ack(skb, nlh, 0);
533 return; 533 return;
534} 534}
535 535
536static void 536static void
@@ -540,19 +540,19 @@ ipq_rcv_sk(struct sock *sk, int len)
540 unsigned int qlen; 540 unsigned int qlen;
541 541
542 mutex_lock(&ipqnl_mutex); 542 mutex_lock(&ipqnl_mutex);
543 543
544 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) { 544 for (qlen = skb_queue_len(&sk->sk_receive_queue); qlen; qlen--) {
545 skb = skb_dequeue(&sk->sk_receive_queue); 545 skb = skb_dequeue(&sk->sk_receive_queue);
546 ipq_rcv_skb(skb); 546 ipq_rcv_skb(skb);
547 kfree_skb(skb); 547 kfree_skb(skb);
548 } 548 }
549 549
550 mutex_unlock(&ipqnl_mutex); 550 mutex_unlock(&ipqnl_mutex);
551} 551}
552 552
553static int 553static int
554ipq_rcv_dev_event(struct notifier_block *this, 554ipq_rcv_dev_event(struct notifier_block *this,
555 unsigned long event, void *ptr) 555 unsigned long event, void *ptr)
556{ 556{
557 struct net_device *dev = ptr; 557 struct net_device *dev = ptr;
558 558
@@ -568,7 +568,7 @@ static struct notifier_block ipq_dev_notifier = {
568 568
569static int 569static int
570ipq_rcv_nl_event(struct notifier_block *this, 570ipq_rcv_nl_event(struct notifier_block *this,
571 unsigned long event, void *ptr) 571 unsigned long event, void *ptr)
572{ 572{
573 struct netlink_notify *n = ptr; 573 struct netlink_notify *n = ptr;
574 574
@@ -597,7 +597,7 @@ static ctl_table ipq_table[] = {
597 .mode = 0644, 597 .mode = 0644,
598 .proc_handler = proc_dointvec 598 .proc_handler = proc_dointvec
599 }, 599 },
600 { .ctl_name = 0 } 600 { .ctl_name = 0 }
601}; 601};
602 602
603static ctl_table ipq_dir_table[] = { 603static ctl_table ipq_dir_table[] = {
@@ -627,25 +627,25 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
627 int len; 627 int len;
628 628
629 read_lock_bh(&queue_lock); 629 read_lock_bh(&queue_lock);
630 630
631 len = sprintf(buffer, 631 len = sprintf(buffer,
632 "Peer PID : %d\n" 632 "Peer PID : %d\n"
633 "Copy mode : %hu\n" 633 "Copy mode : %hu\n"
634 "Copy range : %u\n" 634 "Copy range : %u\n"
635 "Queue length : %u\n" 635 "Queue length : %u\n"
636 "Queue max. length : %u\n" 636 "Queue max. length : %u\n"
637 "Queue dropped : %u\n" 637 "Queue dropped : %u\n"
638 "Netfilter dropped : %u\n", 638 "Netfilter dropped : %u\n",
639 peer_pid, 639 peer_pid,
640 copy_mode, 640 copy_mode,
641 copy_range, 641 copy_range,
642 queue_total, 642 queue_total,
643 queue_maxlen, 643 queue_maxlen,
644 queue_dropped, 644 queue_dropped,
645 queue_user_dropped); 645 queue_user_dropped);
646 646
647 read_unlock_bh(&queue_lock); 647 read_unlock_bh(&queue_lock);
648 648
649 *start = buffer + offset; 649 *start = buffer + offset;
650 len -= offset; 650 len -= offset;
651 if (len > length) 651 if (len > length)
@@ -665,10 +665,10 @@ static int __init ip6_queue_init(void)
665{ 665{
666 int status = -ENOMEM; 666 int status = -ENOMEM;
667 struct proc_dir_entry *proc; 667 struct proc_dir_entry *proc;
668 668
669 netlink_register_notifier(&ipq_nl_notifier); 669 netlink_register_notifier(&ipq_nl_notifier);
670 ipqnl = netlink_kernel_create(NETLINK_IP6_FW, 0, ipq_rcv_sk, 670 ipqnl = netlink_kernel_create(NETLINK_IP6_FW, 0, ipq_rcv_sk,
671 THIS_MODULE); 671 THIS_MODULE);
672 if (ipqnl == NULL) { 672 if (ipqnl == NULL) {
673 printk(KERN_ERR "ip6_queue: failed to create netlink socket\n"); 673 printk(KERN_ERR "ip6_queue: failed to create netlink socket\n");
674 goto cleanup_netlink_notifier; 674 goto cleanup_netlink_notifier;
@@ -681,10 +681,10 @@ static int __init ip6_queue_init(void)
681 printk(KERN_ERR "ip6_queue: failed to create proc entry\n"); 681 printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
682 goto cleanup_ipqnl; 682 goto cleanup_ipqnl;
683 } 683 }
684 684
685 register_netdevice_notifier(&ipq_dev_notifier); 685 register_netdevice_notifier(&ipq_dev_notifier);
686 ipq_sysctl_header = register_sysctl_table(ipq_root_table, 0); 686 ipq_sysctl_header = register_sysctl_table(ipq_root_table, 0);
687 687
688 status = nf_register_queue_handler(PF_INET6, &nfqh); 688 status = nf_register_queue_handler(PF_INET6, &nfqh);
689 if (status < 0) { 689 if (status < 0) {
690 printk(KERN_ERR "ip6_queue: failed to register queue handler\n"); 690 printk(KERN_ERR "ip6_queue: failed to register queue handler\n");
@@ -696,12 +696,12 @@ cleanup_sysctl:
696 unregister_sysctl_table(ipq_sysctl_header); 696 unregister_sysctl_table(ipq_sysctl_header);
697 unregister_netdevice_notifier(&ipq_dev_notifier); 697 unregister_netdevice_notifier(&ipq_dev_notifier);
698 proc_net_remove(IPQ_PROC_FS_NAME); 698 proc_net_remove(IPQ_PROC_FS_NAME);
699 699
700cleanup_ipqnl: 700cleanup_ipqnl:
701 sock_release(ipqnl->sk_socket); 701 sock_release(ipqnl->sk_socket);
702 mutex_lock(&ipqnl_mutex); 702 mutex_lock(&ipqnl_mutex);
703 mutex_unlock(&ipqnl_mutex); 703 mutex_unlock(&ipqnl_mutex);
704 704
705cleanup_netlink_notifier: 705cleanup_netlink_notifier:
706 netlink_unregister_notifier(&ipq_nl_notifier); 706 netlink_unregister_notifier(&ipq_nl_notifier);
707 return status; 707 return status;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 99502c5da4c4..7c512e13f956 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -92,16 +92,16 @@ do { \
92#endif 92#endif
93 93
94/* Check for an extension */ 94/* Check for an extension */
95int 95int
96ip6t_ext_hdr(u8 nexthdr) 96ip6t_ext_hdr(u8 nexthdr)
97{ 97{
98 return ( (nexthdr == IPPROTO_HOPOPTS) || 98 return ( (nexthdr == IPPROTO_HOPOPTS) ||
99 (nexthdr == IPPROTO_ROUTING) || 99 (nexthdr == IPPROTO_ROUTING) ||
100 (nexthdr == IPPROTO_FRAGMENT) || 100 (nexthdr == IPPROTO_FRAGMENT) ||
101 (nexthdr == IPPROTO_ESP) || 101 (nexthdr == IPPROTO_ESP) ||
102 (nexthdr == IPPROTO_AH) || 102 (nexthdr == IPPROTO_AH) ||
103 (nexthdr == IPPROTO_NONE) || 103 (nexthdr == IPPROTO_NONE) ||
104 (nexthdr == IPPROTO_DSTOPTS) ); 104 (nexthdr == IPPROTO_DSTOPTS) );
105} 105}
106 106
107/* Returns whether matches rule or not. */ 107/* Returns whether matches rule or not. */
@@ -120,9 +120,9 @@ ip6_packet_match(const struct sk_buff *skb,
120#define FWINV(bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg)) 120#define FWINV(bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg))
121 121
122 if (FWINV(ipv6_masked_addr_cmp(&ipv6->saddr, &ip6info->smsk, 122 if (FWINV(ipv6_masked_addr_cmp(&ipv6->saddr, &ip6info->smsk,
123 &ip6info->src), IP6T_INV_SRCIP) 123 &ip6info->src), IP6T_INV_SRCIP)
124 || FWINV(ipv6_masked_addr_cmp(&ipv6->daddr, &ip6info->dmsk, 124 || FWINV(ipv6_masked_addr_cmp(&ipv6->daddr, &ip6info->dmsk,
125 &ip6info->dst), IP6T_INV_DSTIP)) { 125 &ip6info->dst), IP6T_INV_DSTIP)) {
126 dprintf("Source or dest mismatch.\n"); 126 dprintf("Source or dest mismatch.\n");
127/* 127/*
128 dprintf("SRC: %u. Mask: %u. Target: %u.%s\n", ip->saddr, 128 dprintf("SRC: %u. Mask: %u. Target: %u.%s\n", ip->saddr,
@@ -177,7 +177,7 @@ ip6_packet_match(const struct sk_buff *skb,
177 *fragoff = _frag_off; 177 *fragoff = _frag_off;
178 178
179 dprintf("Packet protocol %hi ?= %s%hi.\n", 179 dprintf("Packet protocol %hi ?= %s%hi.\n",
180 protohdr, 180 protohdr,
181 ip6info->invflags & IP6T_INV_PROTO ? "!":"", 181 ip6info->invflags & IP6T_INV_PROTO ? "!":"",
182 ip6info->proto); 182 ip6info->proto);
183 183
@@ -197,7 +197,7 @@ ip6_packet_match(const struct sk_buff *skb,
197} 197}
198 198
199/* should be ip6 safe */ 199/* should be ip6 safe */
200static inline int 200static inline int
201ip6_checkentry(const struct ip6t_ip6 *ipv6) 201ip6_checkentry(const struct ip6t_ip6 *ipv6)
202{ 202{
203 if (ipv6->flags & ~IP6T_F_MASK) { 203 if (ipv6->flags & ~IP6T_F_MASK) {
@@ -337,7 +337,7 @@ ip6t_do_table(struct sk_buff **pskb,
337 e = get_entry(table_base, v); 337 e = get_entry(table_base, v);
338 } else { 338 } else {
339 /* Targets which reenter must return 339 /* Targets which reenter must return
340 abs. verdicts */ 340 abs. verdicts */
341#ifdef CONFIG_NETFILTER_DEBUG 341#ifdef CONFIG_NETFILTER_DEBUG
342 ((struct ip6t_entry *)table_base)->comefrom 342 ((struct ip6t_entry *)table_base)->comefrom
343 = 0xeeeeeeec; 343 = 0xeeeeeeec;
@@ -530,14 +530,14 @@ check_match(struct ip6t_entry_match *m,
530 unsigned int hookmask, 530 unsigned int hookmask,
531 unsigned int *i) 531 unsigned int *i)
532{ 532{
533 struct ip6t_match *match; 533 struct xt_match *match;
534 int ret; 534 int ret;
535 535
536 match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name, 536 match = try_then_request_module(xt_find_match(AF_INET6, m->u.user.name,
537 m->u.user.revision), 537 m->u.user.revision),
538 "ip6t_%s", m->u.user.name); 538 "ip6t_%s", m->u.user.name);
539 if (IS_ERR(match) || !match) { 539 if (IS_ERR(match) || !match) {
540 duprintf("check_match: `%s' not found\n", m->u.user.name); 540 duprintf("check_match: `%s' not found\n", m->u.user.name);
541 return match ? PTR_ERR(match) : -ENOENT; 541 return match ? PTR_ERR(match) : -ENOENT;
542 } 542 }
543 m->u.kernel.match = match; 543 m->u.kernel.match = match;
@@ -564,14 +564,14 @@ err:
564 return ret; 564 return ret;
565} 565}
566 566
567static struct ip6t_target ip6t_standard_target; 567static struct xt_target ip6t_standard_target;
568 568
569static inline int 569static inline int
570check_entry(struct ip6t_entry *e, const char *name, unsigned int size, 570check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
571 unsigned int *i) 571 unsigned int *i)
572{ 572{
573 struct ip6t_entry_target *t; 573 struct ip6t_entry_target *t;
574 struct ip6t_target *target; 574 struct xt_target *target;
575 int ret; 575 int ret;
576 unsigned int j; 576 unsigned int j;
577 577
@@ -661,7 +661,7 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
661 } 661 }
662 662
663 /* FIXME: underflows must be unconditional, standard verdicts 663 /* FIXME: underflows must be unconditional, standard verdicts
664 < 0 (not IP6T_RETURN). --RR */ 664 < 0 (not IP6T_RETURN). --RR */
665 665
666 /* Clear counters and comefrom */ 666 /* Clear counters and comefrom */
667 e->counters = ((struct xt_counters) { 0, 0 }); 667 e->counters = ((struct xt_counters) { 0, 0 });
@@ -1003,8 +1003,8 @@ do_replace(void __user *user, unsigned int len)
1003 /* Update module usage count based on number of rules */ 1003 /* Update module usage count based on number of rules */
1004 duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n", 1004 duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n",
1005 oldinfo->number, oldinfo->initial_entries, newinfo->number); 1005 oldinfo->number, oldinfo->initial_entries, newinfo->number);
1006 if ((oldinfo->number > oldinfo->initial_entries) || 1006 if ((oldinfo->number > oldinfo->initial_entries) ||
1007 (newinfo->number <= oldinfo->initial_entries)) 1007 (newinfo->number <= oldinfo->initial_entries))
1008 module_put(t->me); 1008 module_put(t->me);
1009 if ((oldinfo->number > oldinfo->initial_entries) && 1009 if ((oldinfo->number > oldinfo->initial_entries) &&
1010 (newinfo->number <= oldinfo->initial_entries)) 1010 (newinfo->number <= oldinfo->initial_entries))
@@ -1348,13 +1348,13 @@ icmp6_checkentry(const char *tablename,
1348} 1348}
1349 1349
1350/* The built-in targets: standard (NULL) and error. */ 1350/* The built-in targets: standard (NULL) and error. */
1351static struct ip6t_target ip6t_standard_target = { 1351static struct xt_target ip6t_standard_target = {
1352 .name = IP6T_STANDARD_TARGET, 1352 .name = IP6T_STANDARD_TARGET,
1353 .targetsize = sizeof(int), 1353 .targetsize = sizeof(int),
1354 .family = AF_INET6, 1354 .family = AF_INET6,
1355}; 1355};
1356 1356
1357static struct ip6t_target ip6t_error_target = { 1357static struct xt_target ip6t_error_target = {
1358 .name = IP6T_ERROR_TARGET, 1358 .name = IP6T_ERROR_TARGET,
1359 .target = ip6t_error, 1359 .target = ip6t_error,
1360 .targetsize = IP6T_FUNCTION_MAXNAMELEN, 1360 .targetsize = IP6T_FUNCTION_MAXNAMELEN,
@@ -1371,7 +1371,7 @@ static struct nf_sockopt_ops ip6t_sockopts = {
1371 .get = do_ip6t_get_ctl, 1371 .get = do_ip6t_get_ctl,
1372}; 1372};
1373 1373
1374static struct ip6t_match icmp6_matchstruct = { 1374static struct xt_match icmp6_matchstruct = {
1375 .name = "icmp6", 1375 .name = "icmp6",
1376 .match = &icmp6_match, 1376 .match = &icmp6_match,
1377 .matchsize = sizeof(struct ip6t_icmp), 1377 .matchsize = sizeof(struct ip6t_icmp),
@@ -1492,9 +1492,9 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
1492 } 1492 }
1493 hdrlen = 8; 1493 hdrlen = 8;
1494 } else if (nexthdr == NEXTHDR_AUTH) 1494 } else if (nexthdr == NEXTHDR_AUTH)
1495 hdrlen = (hp->hdrlen + 2) << 2; 1495 hdrlen = (hp->hdrlen + 2) << 2;
1496 else 1496 else
1497 hdrlen = ipv6_optlen(hp); 1497 hdrlen = ipv6_optlen(hp);
1498 1498
1499 nexthdr = hp->nexthdr; 1499 nexthdr = hp->nexthdr;
1500 len -= hdrlen; 1500 len -= hdrlen;
diff --git a/net/ipv6/netfilter/ip6t_HL.c b/net/ipv6/netfilter/ip6t_HL.c
index 435750f664dd..ccbab66277e3 100644
--- a/net/ipv6/netfilter/ip6t_HL.c
+++ b/net/ipv6/netfilter/ip6t_HL.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Hop Limit modification target for ip6tables 2 * Hop Limit modification target for ip6tables
3 * Maciej Soltysiak <solt@dns.toxicfilms.tv> 3 * Maciej Soltysiak <solt@dns.toxicfilms.tv>
4 * Based on HW's TTL module 4 * Based on HW's TTL module
@@ -9,15 +9,16 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/skbuff.h> 10#include <linux/skbuff.h>
11#include <linux/ip.h> 11#include <linux/ip.h>
12#include <linux/ipv6.h>
12 13
13#include <linux/netfilter_ipv6/ip6_tables.h> 14#include <linux/netfilter/x_tables.h>
14#include <linux/netfilter_ipv6/ip6t_HL.h> 15#include <linux/netfilter_ipv6/ip6t_HL.h>
15 16
16MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>"); 17MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
17MODULE_DESCRIPTION("IP tables Hop Limit modification module"); 18MODULE_DESCRIPTION("IP6 tables Hop Limit modification module");
18MODULE_LICENSE("GPL"); 19MODULE_LICENSE("GPL");
19 20
20static unsigned int ip6t_hl_target(struct sk_buff **pskb, 21static unsigned int ip6t_hl_target(struct sk_buff **pskb,
21 const struct net_device *in, 22 const struct net_device *in,
22 const struct net_device *out, 23 const struct net_device *out,
23 unsigned int hooknum, 24 unsigned int hooknum,
@@ -52,10 +53,9 @@ static unsigned int ip6t_hl_target(struct sk_buff **pskb,
52 break; 53 break;
53 } 54 }
54 55
55 if (new_hl != ip6h->hop_limit) 56 ip6h->hop_limit = new_hl;
56 ip6h->hop_limit = new_hl;
57 57
58 return IP6T_CONTINUE; 58 return XT_CONTINUE;
59} 59}
60 60
61static int ip6t_hl_checkentry(const char *tablename, 61static int ip6t_hl_checkentry(const char *tablename,
@@ -67,7 +67,7 @@ static int ip6t_hl_checkentry(const char *tablename,
67 struct ip6t_HL_info *info = targinfo; 67 struct ip6t_HL_info *info = targinfo;
68 68
69 if (info->mode > IP6T_HL_MAXMODE) { 69 if (info->mode > IP6T_HL_MAXMODE) {
70 printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n", 70 printk(KERN_WARNING "ip6t_HL: invalid or unknown Mode %u\n",
71 info->mode); 71 info->mode);
72 return 0; 72 return 0;
73 } 73 }
@@ -79,23 +79,24 @@ static int ip6t_hl_checkentry(const char *tablename,
79 return 1; 79 return 1;
80} 80}
81 81
82static struct ip6t_target ip6t_HL = { 82static struct xt_target ip6t_HL = {
83 .name = "HL", 83 .name = "HL",
84 .target = ip6t_hl_target, 84 .family = AF_INET6,
85 .target = ip6t_hl_target,
85 .targetsize = sizeof(struct ip6t_HL_info), 86 .targetsize = sizeof(struct ip6t_HL_info),
86 .table = "mangle", 87 .table = "mangle",
87 .checkentry = ip6t_hl_checkentry, 88 .checkentry = ip6t_hl_checkentry,
88 .me = THIS_MODULE 89 .me = THIS_MODULE
89}; 90};
90 91
91static int __init ip6t_hl_init(void) 92static int __init ip6t_hl_init(void)
92{ 93{
93 return ip6t_register_target(&ip6t_HL); 94 return xt_register_target(&ip6t_HL);
94} 95}
95 96
96static void __exit ip6t_hl_fini(void) 97static void __exit ip6t_hl_fini(void)
97{ 98{
98 ip6t_unregister_target(&ip6t_HL); 99 xt_unregister_target(&ip6t_HL);
99} 100}
100 101
101module_init(ip6t_hl_init); 102module_init(ip6t_hl_init);
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index 33b1faa90d74..afaa039d0b7b 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -21,6 +21,7 @@
21#include <net/tcp.h> 21#include <net/tcp.h>
22#include <net/ipv6.h> 22#include <net/ipv6.h>
23#include <linux/netfilter.h> 23#include <linux/netfilter.h>
24#include <linux/netfilter/x_tables.h>
24#include <linux/netfilter_ipv6/ip6_tables.h> 25#include <linux/netfilter_ipv6/ip6_tables.h>
25 26
26MODULE_AUTHOR("Jan Rekorajski <baggins@pld.org.pl>"); 27MODULE_AUTHOR("Jan Rekorajski <baggins@pld.org.pl>");
@@ -144,7 +145,7 @@ static void dump_packet(const struct nf_loginfo *info,
144 &_ahdr); 145 &_ahdr);
145 if (ah == NULL) { 146 if (ah == NULL) {
146 /* 147 /*
147 * Max length: 26 "INCOMPLETE [65535 148 * Max length: 26 "INCOMPLETE [65535
148 * bytes] )" 149 * bytes] )"
149 */ 150 */
150 printk("INCOMPLETE [%u bytes] )", 151 printk("INCOMPLETE [%u bytes] )",
@@ -386,7 +387,7 @@ ip6t_log_packet(unsigned int pf,
386 loginfo = &default_loginfo; 387 loginfo = &default_loginfo;
387 388
388 spin_lock_bh(&log_lock); 389 spin_lock_bh(&log_lock);
389 printk("<%d>%sIN=%s OUT=%s ", loginfo->u.log.level, 390 printk("<%d>%sIN=%s OUT=%s ", loginfo->u.log.level,
390 prefix, 391 prefix,
391 in ? in->name : "", 392 in ? in->name : "",
392 out ? out->name : ""); 393 out ? out->name : "");
@@ -441,8 +442,8 @@ ip6t_log_target(struct sk_buff **pskb,
441 li.u.log.logflags = loginfo->logflags; 442 li.u.log.logflags = loginfo->logflags;
442 443
443 ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li, 444 ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
444 loginfo->prefix); 445 loginfo->prefix);
445 return IP6T_CONTINUE; 446 return XT_CONTINUE;
446} 447}
447 448
448 449
@@ -466,11 +467,12 @@ static int ip6t_log_checkentry(const char *tablename,
466 return 1; 467 return 1;
467} 468}
468 469
469static struct ip6t_target ip6t_log_reg = { 470static struct xt_target ip6t_log_reg = {
470 .name = "LOG", 471 .name = "LOG",
471 .target = ip6t_log_target, 472 .family = AF_INET6,
473 .target = ip6t_log_target,
472 .targetsize = sizeof(struct ip6t_log_info), 474 .targetsize = sizeof(struct ip6t_log_info),
473 .checkentry = ip6t_log_checkentry, 475 .checkentry = ip6t_log_checkentry,
474 .me = THIS_MODULE, 476 .me = THIS_MODULE,
475}; 477};
476 478
@@ -482,8 +484,11 @@ static struct nf_logger ip6t_logger = {
482 484
483static int __init ip6t_log_init(void) 485static int __init ip6t_log_init(void)
484{ 486{
485 if (ip6t_register_target(&ip6t_log_reg)) 487 int ret;
486 return -EINVAL; 488
489 ret = xt_register_target(&ip6t_log_reg);
490 if (ret < 0)
491 return ret;
487 if (nf_log_register(PF_INET6, &ip6t_logger) < 0) { 492 if (nf_log_register(PF_INET6, &ip6t_logger) < 0) {
488 printk(KERN_WARNING "ip6t_LOG: not logging via system console " 493 printk(KERN_WARNING "ip6t_LOG: not logging via system console "
489 "since somebody else already registered for PF_INET6\n"); 494 "since somebody else already registered for PF_INET6\n");
@@ -496,8 +501,8 @@ static int __init ip6t_log_init(void)
496 501
497static void __exit ip6t_log_fini(void) 502static void __exit ip6t_log_fini(void)
498{ 503{
499 nf_log_unregister_logger(&ip6t_logger); 504 nf_log_unregister(&ip6t_logger);
500 ip6t_unregister_target(&ip6t_log_reg); 505 xt_unregister_target(&ip6t_log_reg);
501} 506}
502 507
503module_init(ip6t_log_init); 508module_init(ip6t_log_init);
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c
index 311eae82feb3..6abee94c929f 100644
--- a/net/ipv6/netfilter/ip6t_REJECT.c
+++ b/net/ipv6/netfilter/ip6t_REJECT.c
@@ -26,6 +26,7 @@
26#include <net/ip6_fib.h> 26#include <net/ip6_fib.h>
27#include <net/ip6_route.h> 27#include <net/ip6_route.h>
28#include <net/flow.h> 28#include <net/flow.h>
29#include <linux/netfilter/x_tables.h>
29#include <linux/netfilter_ipv6/ip6_tables.h> 30#include <linux/netfilter_ipv6/ip6_tables.h>
30#include <linux/netfilter_ipv6/ip6t_REJECT.h> 31#include <linux/netfilter_ipv6/ip6t_REJECT.h>
31 32
@@ -188,23 +189,23 @@ static unsigned int reject6_target(struct sk_buff **pskb,
188 /* WARNING: This code causes reentry within ip6tables. 189 /* WARNING: This code causes reentry within ip6tables.
189 This means that the ip6tables jump stack is now crap. We 190 This means that the ip6tables jump stack is now crap. We
190 must return an absolute verdict. --RR */ 191 must return an absolute verdict. --RR */
191 switch (reject->with) { 192 switch (reject->with) {
192 case IP6T_ICMP6_NO_ROUTE: 193 case IP6T_ICMP6_NO_ROUTE:
193 send_unreach(*pskb, ICMPV6_NOROUTE, hooknum); 194 send_unreach(*pskb, ICMPV6_NOROUTE, hooknum);
194 break; 195 break;
195 case IP6T_ICMP6_ADM_PROHIBITED: 196 case IP6T_ICMP6_ADM_PROHIBITED:
196 send_unreach(*pskb, ICMPV6_ADM_PROHIBITED, hooknum); 197 send_unreach(*pskb, ICMPV6_ADM_PROHIBITED, hooknum);
197 break; 198 break;
198 case IP6T_ICMP6_NOT_NEIGHBOUR: 199 case IP6T_ICMP6_NOT_NEIGHBOUR:
199 send_unreach(*pskb, ICMPV6_NOT_NEIGHBOUR, hooknum); 200 send_unreach(*pskb, ICMPV6_NOT_NEIGHBOUR, hooknum);
200 break; 201 break;
201 case IP6T_ICMP6_ADDR_UNREACH: 202 case IP6T_ICMP6_ADDR_UNREACH:
202 send_unreach(*pskb, ICMPV6_ADDR_UNREACH, hooknum); 203 send_unreach(*pskb, ICMPV6_ADDR_UNREACH, hooknum);
203 break; 204 break;
204 case IP6T_ICMP6_PORT_UNREACH: 205 case IP6T_ICMP6_PORT_UNREACH:
205 send_unreach(*pskb, ICMPV6_PORT_UNREACH, hooknum); 206 send_unreach(*pskb, ICMPV6_PORT_UNREACH, hooknum);
206 break; 207 break;
207 case IP6T_ICMP6_ECHOREPLY: 208 case IP6T_ICMP6_ECHOREPLY:
208 /* Do nothing */ 209 /* Do nothing */
209 break; 210 break;
210 case IP6T_TCP_RESET: 211 case IP6T_TCP_RESET:
@@ -225,7 +226,7 @@ static int check(const char *tablename,
225 void *targinfo, 226 void *targinfo,
226 unsigned int hook_mask) 227 unsigned int hook_mask)
227{ 228{
228 const struct ip6t_reject_info *rejinfo = targinfo; 229 const struct ip6t_reject_info *rejinfo = targinfo;
229 const struct ip6t_entry *e = entry; 230 const struct ip6t_entry *e = entry;
230 231
231 if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) { 232 if (rejinfo->with == IP6T_ICMP6_ECHOREPLY) {
@@ -234,7 +235,7 @@ static int check(const char *tablename,
234 } else if (rejinfo->with == IP6T_TCP_RESET) { 235 } else if (rejinfo->with == IP6T_TCP_RESET) {
235 /* Must specify that it's a TCP packet */ 236 /* Must specify that it's a TCP packet */
236 if (e->ipv6.proto != IPPROTO_TCP 237 if (e->ipv6.proto != IPPROTO_TCP
237 || (e->ipv6.invflags & IP6T_INV_PROTO)) { 238 || (e->ipv6.invflags & XT_INV_PROTO)) {
238 DEBUGP("ip6t_REJECT: TCP_RESET illegal for non-tcp\n"); 239 DEBUGP("ip6t_REJECT: TCP_RESET illegal for non-tcp\n");
239 return 0; 240 return 0;
240 } 241 }
@@ -242,8 +243,9 @@ static int check(const char *tablename,
242 return 1; 243 return 1;
243} 244}
244 245
245static struct ip6t_target ip6t_reject_reg = { 246static struct xt_target ip6t_reject_reg = {
246 .name = "REJECT", 247 .name = "REJECT",
248 .family = AF_INET6,
247 .target = reject6_target, 249 .target = reject6_target,
248 .targetsize = sizeof(struct ip6t_reject_info), 250 .targetsize = sizeof(struct ip6t_reject_info),
249 .table = "filter", 251 .table = "filter",
@@ -255,12 +257,12 @@ static struct ip6t_target ip6t_reject_reg = {
255 257
256static int __init ip6t_reject_init(void) 258static int __init ip6t_reject_init(void)
257{ 259{
258 return ip6t_register_target(&ip6t_reject_reg); 260 return xt_register_target(&ip6t_reject_reg);
259} 261}
260 262
261static void __exit ip6t_reject_fini(void) 263static void __exit ip6t_reject_fini(void)
262{ 264{
263 ip6t_unregister_target(&ip6t_reject_reg); 265 xt_unregister_target(&ip6t_reject_reg);
264} 266}
265 267
266module_init(ip6t_reject_init); 268module_init(ip6t_reject_init);
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c
index 46486645eb75..d3c154371b41 100644
--- a/net/ipv6/netfilter/ip6t_ah.c
+++ b/net/ipv6/netfilter/ip6t_ah.c
@@ -15,6 +15,7 @@
15#include <net/checksum.h> 15#include <net/checksum.h>
16#include <net/ipv6.h> 16#include <net/ipv6.h>
17 17
18#include <linux/netfilter/x_tables.h>
18#include <linux/netfilter_ipv6/ip6_tables.h> 19#include <linux/netfilter_ipv6/ip6_tables.h>
19#include <linux/netfilter_ipv6/ip6t_ah.h> 20#include <linux/netfilter_ipv6/ip6t_ah.h>
20 21
@@ -77,13 +78,13 @@ match(const struct sk_buff *skb,
77 78
78 DEBUGP("IPv6 AH spi %02X ", 79 DEBUGP("IPv6 AH spi %02X ",
79 (spi_match(ahinfo->spis[0], ahinfo->spis[1], 80 (spi_match(ahinfo->spis[0], ahinfo->spis[1],
80 ntohl(ah->spi), 81 ntohl(ah->spi),
81 !!(ahinfo->invflags & IP6T_AH_INV_SPI)))); 82 !!(ahinfo->invflags & IP6T_AH_INV_SPI))));
82 DEBUGP("len %02X %04X %02X ", 83 DEBUGP("len %02X %04X %02X ",
83 ahinfo->hdrlen, hdrlen, 84 ahinfo->hdrlen, hdrlen,
84 (!ahinfo->hdrlen || 85 (!ahinfo->hdrlen ||
85 (ahinfo->hdrlen == hdrlen) ^ 86 (ahinfo->hdrlen == hdrlen) ^
86 !!(ahinfo->invflags & IP6T_AH_INV_LEN))); 87 !!(ahinfo->invflags & IP6T_AH_INV_LEN)));
87 DEBUGP("res %02X %04X %02X\n", 88 DEBUGP("res %02X %04X %02X\n",
88 ahinfo->hdrres, ah->reserved, 89 ahinfo->hdrres, ah->reserved,
89 !(ahinfo->hdrres && ah->reserved)); 90 !(ahinfo->hdrres && ah->reserved));
@@ -91,12 +92,12 @@ match(const struct sk_buff *skb,
91 return (ah != NULL) 92 return (ah != NULL)
92 && 93 &&
93 (spi_match(ahinfo->spis[0], ahinfo->spis[1], 94 (spi_match(ahinfo->spis[0], ahinfo->spis[1],
94 ntohl(ah->spi), 95 ntohl(ah->spi),
95 !!(ahinfo->invflags & IP6T_AH_INV_SPI))) 96 !!(ahinfo->invflags & IP6T_AH_INV_SPI)))
96 && 97 &&
97 (!ahinfo->hdrlen || 98 (!ahinfo->hdrlen ||
98 (ahinfo->hdrlen == hdrlen) ^ 99 (ahinfo->hdrlen == hdrlen) ^
99 !!(ahinfo->invflags & IP6T_AH_INV_LEN)) 100 !!(ahinfo->invflags & IP6T_AH_INV_LEN))
100 && 101 &&
101 !(ahinfo->hdrres && ah->reserved); 102 !(ahinfo->hdrres && ah->reserved);
102} 103}
@@ -104,10 +105,10 @@ match(const struct sk_buff *skb,
104/* Called when user tries to insert an entry of this type. */ 105/* Called when user tries to insert an entry of this type. */
105static int 106static int
106checkentry(const char *tablename, 107checkentry(const char *tablename,
107 const void *entry, 108 const void *entry,
108 const struct xt_match *match, 109 const struct xt_match *match,
109 void *matchinfo, 110 void *matchinfo,
110 unsigned int hook_mask) 111 unsigned int hook_mask)
111{ 112{
112 const struct ip6t_ah *ahinfo = matchinfo; 113 const struct ip6t_ah *ahinfo = matchinfo;
113 114
@@ -118,8 +119,9 @@ checkentry(const char *tablename,
118 return 1; 119 return 1;
119} 120}
120 121
121static struct ip6t_match ah_match = { 122static struct xt_match ah_match = {
122 .name = "ah", 123 .name = "ah",
124 .family = AF_INET6,
123 .match = match, 125 .match = match,
124 .matchsize = sizeof(struct ip6t_ah), 126 .matchsize = sizeof(struct ip6t_ah),
125 .checkentry = checkentry, 127 .checkentry = checkentry,
@@ -128,12 +130,12 @@ static struct ip6t_match ah_match = {
128 130
129static int __init ip6t_ah_init(void) 131static int __init ip6t_ah_init(void)
130{ 132{
131 return ip6t_register_match(&ah_match); 133 return xt_register_match(&ah_match);
132} 134}
133 135
134static void __exit ip6t_ah_fini(void) 136static void __exit ip6t_ah_fini(void)
135{ 137{
136 ip6t_unregister_match(&ah_match); 138 xt_unregister_match(&ah_match);
137} 139}
138 140
139module_init(ip6t_ah_init); 141module_init(ip6t_ah_init);
diff --git a/net/ipv6/netfilter/ip6t_eui64.c b/net/ipv6/netfilter/ip6t_eui64.c
index 4f6b84c8f4ab..967bed71d4a8 100644
--- a/net/ipv6/netfilter/ip6t_eui64.c
+++ b/net/ipv6/netfilter/ip6t_eui64.c
@@ -12,6 +12,7 @@
12#include <linux/ipv6.h> 12#include <linux/ipv6.h>
13#include <linux/if_ether.h> 13#include <linux/if_ether.h>
14 14
15#include <linux/netfilter/x_tables.h>
15#include <linux/netfilter_ipv6/ip6_tables.h> 16#include <linux/netfilter_ipv6/ip6_tables.h>
16 17
17MODULE_DESCRIPTION("IPv6 EUI64 address checking match"); 18MODULE_DESCRIPTION("IPv6 EUI64 address checking match");
@@ -61,8 +62,9 @@ match(const struct sk_buff *skb,
61 return 0; 62 return 0;
62} 63}
63 64
64static struct ip6t_match eui64_match = { 65static struct xt_match eui64_match = {
65 .name = "eui64", 66 .name = "eui64",
67 .family = AF_INET6,
66 .match = match, 68 .match = match,
67 .matchsize = sizeof(int), 69 .matchsize = sizeof(int),
68 .hooks = (1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_IN) | 70 .hooks = (1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_IN) |
@@ -72,12 +74,12 @@ static struct ip6t_match eui64_match = {
72 74
73static int __init ip6t_eui64_init(void) 75static int __init ip6t_eui64_init(void)
74{ 76{
75 return ip6t_register_match(&eui64_match); 77 return xt_register_match(&eui64_match);
76} 78}
77 79
78static void __exit ip6t_eui64_fini(void) 80static void __exit ip6t_eui64_fini(void)
79{ 81{
80 ip6t_unregister_match(&eui64_match); 82 xt_unregister_match(&eui64_match);
81} 83}
82 84
83module_init(ip6t_eui64_init); 85module_init(ip6t_eui64_init);
diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c
index cd22eaaccdca..5a5da71321b6 100644
--- a/net/ipv6/netfilter/ip6t_frag.c
+++ b/net/ipv6/netfilter/ip6t_frag.c
@@ -14,6 +14,7 @@
14#include <net/checksum.h> 14#include <net/checksum.h>
15#include <net/ipv6.h> 15#include <net/ipv6.h>
16 16
17#include <linux/netfilter/x_tables.h>
17#include <linux/netfilter_ipv6/ip6_tables.h> 18#include <linux/netfilter_ipv6/ip6_tables.h>
18#include <linux/netfilter_ipv6/ip6t_frag.h> 19#include <linux/netfilter_ipv6/ip6t_frag.h>
19 20
@@ -135,8 +136,9 @@ checkentry(const char *tablename,
135 return 1; 136 return 1;
136} 137}
137 138
138static struct ip6t_match frag_match = { 139static struct xt_match frag_match = {
139 .name = "frag", 140 .name = "frag",
141 .family = AF_INET6,
140 .match = match, 142 .match = match,
141 .matchsize = sizeof(struct ip6t_frag), 143 .matchsize = sizeof(struct ip6t_frag),
142 .checkentry = checkentry, 144 .checkentry = checkentry,
@@ -145,12 +147,12 @@ static struct ip6t_match frag_match = {
145 147
146static int __init ip6t_frag_init(void) 148static int __init ip6t_frag_init(void)
147{ 149{
148 return ip6t_register_match(&frag_match); 150 return xt_register_match(&frag_match);
149} 151}
150 152
151static void __exit ip6t_frag_fini(void) 153static void __exit ip6t_frag_fini(void)
152{ 154{
153 ip6t_unregister_match(&frag_match); 155 xt_unregister_match(&frag_match);
154} 156}
155 157
156module_init(ip6t_frag_init); 158module_init(ip6t_frag_init);
diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c
index 3f25babe0440..d2373c7cd354 100644
--- a/net/ipv6/netfilter/ip6t_hbh.c
+++ b/net/ipv6/netfilter/ip6t_hbh.c
@@ -16,6 +16,7 @@
16 16
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18 18
19#include <linux/netfilter/x_tables.h>
19#include <linux/netfilter_ipv6/ip6_tables.h> 20#include <linux/netfilter_ipv6/ip6_tables.h>
20#include <linux/netfilter_ipv6/ip6t_opts.h> 21#include <linux/netfilter_ipv6/ip6t_opts.h>
21 22
diff --git a/net/ipv6/netfilter/ip6t_hl.c b/net/ipv6/netfilter/ip6t_hl.c
index 44a729e17c48..37c8a4d4ed78 100644
--- a/net/ipv6/netfilter/ip6t_hl.c
+++ b/net/ipv6/netfilter/ip6t_hl.c
@@ -8,11 +8,12 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/ipv6.h>
11#include <linux/module.h> 12#include <linux/module.h>
12#include <linux/skbuff.h> 13#include <linux/skbuff.h>
13 14
14#include <linux/netfilter_ipv6/ip6t_hl.h> 15#include <linux/netfilter_ipv6/ip6t_hl.h>
15#include <linux/netfilter_ipv6/ip6_tables.h> 16#include <linux/netfilter/x_tables.h>
16 17
17MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>"); 18MODULE_AUTHOR("Maciej Soltysiak <solt@dns.toxicfilms.tv>");
18MODULE_DESCRIPTION("IP tables Hop Limit matching module"); 19MODULE_DESCRIPTION("IP tables Hop Limit matching module");
@@ -40,7 +41,7 @@ static int match(const struct sk_buff *skb,
40 return (ip6h->hop_limit > info->hop_limit); 41 return (ip6h->hop_limit > info->hop_limit);
41 break; 42 break;
42 default: 43 default:
43 printk(KERN_WARNING "ip6t_hl: unknown mode %d\n", 44 printk(KERN_WARNING "ip6t_hl: unknown mode %d\n",
44 info->mode); 45 info->mode);
45 return 0; 46 return 0;
46 } 47 }
@@ -48,8 +49,9 @@ static int match(const struct sk_buff *skb,
48 return 0; 49 return 0;
49} 50}
50 51
51static struct ip6t_match hl_match = { 52static struct xt_match hl_match = {
52 .name = "hl", 53 .name = "hl",
54 .family = AF_INET6,
53 .match = match, 55 .match = match,
54 .matchsize = sizeof(struct ip6t_hl_info), 56 .matchsize = sizeof(struct ip6t_hl_info),
55 .me = THIS_MODULE, 57 .me = THIS_MODULE,
@@ -57,13 +59,12 @@ static struct ip6t_match hl_match = {
57 59
58static int __init ip6t_hl_init(void) 60static int __init ip6t_hl_init(void)
59{ 61{
60 return ip6t_register_match(&hl_match); 62 return xt_register_match(&hl_match);
61} 63}
62 64
63static void __exit ip6t_hl_fini(void) 65static void __exit ip6t_hl_fini(void)
64{ 66{
65 ip6t_unregister_match(&hl_match); 67 xt_unregister_match(&hl_match);
66
67} 68}
68 69
69module_init(ip6t_hl_init); 70module_init(ip6t_hl_init);
diff --git a/net/ipv6/netfilter/ip6t_ipv6header.c b/net/ipv6/netfilter/ip6t_ipv6header.c
index 3093c398002f..700a11d25deb 100644
--- a/net/ipv6/netfilter/ip6t_ipv6header.c
+++ b/net/ipv6/netfilter/ip6t_ipv6header.c
@@ -1,7 +1,7 @@
1/* ipv6header match - matches IPv6 packets based 1/* ipv6header match - matches IPv6 packets based
2 on whether they contain certain headers */ 2 on whether they contain certain headers */
3 3
4/* Original idea: Brad Chapman 4/* Original idea: Brad Chapman
5 * Rewritten by: Andras Kis-Szabo <kisza@sch.bme.hu> */ 5 * Rewritten by: Andras Kis-Szabo <kisza@sch.bme.hu> */
6 6
7/* (C) 2001-2002 Andras Kis-Szabo <kisza@sch.bme.hu> 7/* (C) 2001-2002 Andras Kis-Szabo <kisza@sch.bme.hu>
@@ -18,6 +18,7 @@
18#include <net/checksum.h> 18#include <net/checksum.h>
19#include <net/ipv6.h> 19#include <net/ipv6.h>
20 20
21#include <linux/netfilter/x_tables.h>
21#include <linux/netfilter_ipv6/ip6_tables.h> 22#include <linux/netfilter_ipv6/ip6_tables.h>
22#include <linux/netfilter_ipv6/ip6t_ipv6header.h> 23#include <linux/netfilter_ipv6/ip6t_ipv6header.h>
23 24
@@ -140,8 +141,9 @@ ipv6header_checkentry(const char *tablename,
140 return 1; 141 return 1;
141} 142}
142 143
143static struct ip6t_match ip6t_ipv6header_match = { 144static struct xt_match ip6t_ipv6header_match = {
144 .name = "ipv6header", 145 .name = "ipv6header",
146 .family = AF_INET6,
145 .match = &ipv6header_match, 147 .match = &ipv6header_match,
146 .matchsize = sizeof(struct ip6t_ipv6header_info), 148 .matchsize = sizeof(struct ip6t_ipv6header_info),
147 .checkentry = &ipv6header_checkentry, 149 .checkentry = &ipv6header_checkentry,
@@ -151,12 +153,12 @@ static struct ip6t_match ip6t_ipv6header_match = {
151 153
152static int __init ipv6header_init(void) 154static int __init ipv6header_init(void)
153{ 155{
154 return ip6t_register_match(&ip6t_ipv6header_match); 156 return xt_register_match(&ip6t_ipv6header_match);
155} 157}
156 158
157static void __exit ipv6header_exit(void) 159static void __exit ipv6header_exit(void)
158{ 160{
159 ip6t_unregister_match(&ip6t_ipv6header_match); 161 xt_unregister_match(&ip6t_ipv6header_match);
160} 162}
161 163
162module_init(ipv6header_init); 164module_init(ipv6header_init);
diff --git a/net/ipv6/netfilter/ip6t_mh.c b/net/ipv6/netfilter/ip6t_mh.c
new file mode 100644
index 000000000000..c2a909893a64
--- /dev/null
+++ b/net/ipv6/netfilter/ip6t_mh.c
@@ -0,0 +1,115 @@
1/*
2 * Copyright (C)2006 USAGI/WIDE Project
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Author:
9 * Masahide NAKAMURA @USAGI <masahide.nakamura.cz@hitachi.com>
10 *
11 * Based on net/netfilter/xt_tcpudp.c
12 *
13 */
14#include <linux/types.h>
15#include <linux/module.h>
16#include <net/ip.h>
17#include <linux/ipv6.h>
18#include <net/ipv6.h>
19#include <net/mip6.h>
20
21#include <linux/netfilter/x_tables.h>
22#include <linux/netfilter_ipv6/ip6t_mh.h>
23
24MODULE_DESCRIPTION("ip6t_tables match for MH");
25MODULE_LICENSE("GPL");
26
27#ifdef DEBUG_IP_FIREWALL_USER
28#define duprintf(format, args...) printk(format , ## args)
29#else
30#define duprintf(format, args...)
31#endif
32
33/* Returns 1 if the type is matched by the range, 0 otherwise */
34static inline int
35type_match(u_int8_t min, u_int8_t max, u_int8_t type, int invert)
36{
37 int ret;
38
39 ret = (type >= min && type <= max) ^ invert;
40 return ret;
41}
42
43static int
44match(const struct sk_buff *skb,
45 const struct net_device *in,
46 const struct net_device *out,
47 const struct xt_match *match,
48 const void *matchinfo,
49 int offset,
50 unsigned int protoff,
51 int *hotdrop)
52{
53 struct ip6_mh _mh, *mh;
54 const struct ip6t_mh *mhinfo = matchinfo;
55
56 /* Must not be a fragment. */
57 if (offset)
58 return 0;
59
60 mh = skb_header_pointer(skb, protoff, sizeof(_mh), &_mh);
61 if (mh == NULL) {
62 /* We've been asked to examine this packet, and we
63 can't. Hence, no choice but to drop. */
64 duprintf("Dropping evil MH tinygram.\n");
65 *hotdrop = 1;
66 return 0;
67 }
68
69 if (mh->ip6mh_proto != IPPROTO_NONE) {
70 duprintf("Dropping invalid MH Payload Proto: %u\n",
71 mh->ip6mh_proto);
72 *hotdrop = 1;
73 return 0;
74 }
75
76 return type_match(mhinfo->types[0], mhinfo->types[1], mh->ip6mh_type,
77 !!(mhinfo->invflags & IP6T_MH_INV_TYPE));
78}
79
80/* Called when user tries to insert an entry of this type. */
81static int
82mh_checkentry(const char *tablename,
83 const void *entry,
84 const struct xt_match *match,
85 void *matchinfo,
86 unsigned int hook_mask)
87{
88 const struct ip6t_mh *mhinfo = matchinfo;
89
90 /* Must specify no unknown invflags */
91 return !(mhinfo->invflags & ~IP6T_MH_INV_MASK);
92}
93
94static struct xt_match mh_match = {
95 .name = "mh",
96 .family = AF_INET6,
97 .checkentry = mh_checkentry,
98 .match = match,
99 .matchsize = sizeof(struct ip6t_mh),
100 .proto = IPPROTO_MH,
101 .me = THIS_MODULE,
102};
103
104static int __init ip6t_mh_init(void)
105{
106 return xt_register_match(&mh_match);
107}
108
109static void __exit ip6t_mh_fini(void)
110{
111 xt_unregister_match(&mh_match);
112}
113
114module_init(ip6t_mh_init);
115module_exit(ip6t_mh_fini);
diff --git a/net/ipv6/netfilter/ip6t_owner.c b/net/ipv6/netfilter/ip6t_owner.c
index 4eb9bbc4ebc3..43738bba00b5 100644
--- a/net/ipv6/netfilter/ip6t_owner.c
+++ b/net/ipv6/netfilter/ip6t_owner.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/netfilter_ipv6/ip6t_owner.h> 17#include <linux/netfilter_ipv6/ip6t_owner.h>
18#include <linux/netfilter_ipv6/ip6_tables.h> 18#include <linux/netfilter_ipv6/ip6_tables.h>
19#include <linux/netfilter/x_tables.h>
19 20
20MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); 21MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
21MODULE_DESCRIPTION("IP6 tables owner matching module"); 22MODULE_DESCRIPTION("IP6 tables owner matching module");
@@ -69,8 +70,9 @@ checkentry(const char *tablename,
69 return 1; 70 return 1;
70} 71}
71 72
72static struct ip6t_match owner_match = { 73static struct xt_match owner_match = {
73 .name = "owner", 74 .name = "owner",
75 .family = AF_INET6,
74 .match = match, 76 .match = match,
75 .matchsize = sizeof(struct ip6t_owner_info), 77 .matchsize = sizeof(struct ip6t_owner_info),
76 .hooks = (1 << NF_IP6_LOCAL_OUT) | (1 << NF_IP6_POST_ROUTING), 78 .hooks = (1 << NF_IP6_LOCAL_OUT) | (1 << NF_IP6_POST_ROUTING),
@@ -80,12 +82,12 @@ static struct ip6t_match owner_match = {
80 82
81static int __init ip6t_owner_init(void) 83static int __init ip6t_owner_init(void)
82{ 84{
83 return ip6t_register_match(&owner_match); 85 return xt_register_match(&owner_match);
84} 86}
85 87
86static void __exit ip6t_owner_fini(void) 88static void __exit ip6t_owner_fini(void)
87{ 89{
88 ip6t_unregister_match(&owner_match); 90 xt_unregister_match(&owner_match);
89} 91}
90 92
91module_init(ip6t_owner_init); 93module_init(ip6t_owner_init);
diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c
index 54d7d14134fd..81ab00d8c182 100644
--- a/net/ipv6/netfilter/ip6t_rt.c
+++ b/net/ipv6/netfilter/ip6t_rt.c
@@ -16,6 +16,7 @@
16 16
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18 18
19#include <linux/netfilter/x_tables.h>
19#include <linux/netfilter_ipv6/ip6_tables.h> 20#include <linux/netfilter_ipv6/ip6_tables.h>
20#include <linux/netfilter_ipv6/ip6t_rt.h> 21#include <linux/netfilter_ipv6/ip6t_rt.h>
21 22
@@ -221,8 +222,9 @@ checkentry(const char *tablename,
221 return 1; 222 return 1;
222} 223}
223 224
224static struct ip6t_match rt_match = { 225static struct xt_match rt_match = {
225 .name = "rt", 226 .name = "rt",
227 .family = AF_INET6,
226 .match = match, 228 .match = match,
227 .matchsize = sizeof(struct ip6t_rt), 229 .matchsize = sizeof(struct ip6t_rt),
228 .checkentry = checkentry, 230 .checkentry = checkentry,
@@ -231,12 +233,12 @@ static struct ip6t_match rt_match = {
231 233
232static int __init ip6t_rt_init(void) 234static int __init ip6t_rt_init(void)
233{ 235{
234 return ip6t_register_match(&rt_match); 236 return xt_register_match(&rt_match);
235} 237}
236 238
237static void __exit ip6t_rt_fini(void) 239static void __exit ip6t_rt_fini(void)
238{ 240{
239 ip6t_unregister_match(&rt_match); 241 xt_unregister_match(&rt_match);
240} 242}
241 243
242module_init(ip6t_rt_init); 244module_init(ip6t_rt_init);
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index 2fc07c74decf..112a21d0c6da 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -19,25 +19,6 @@ MODULE_DESCRIPTION("ip6tables filter table");
19 19
20#define FILTER_VALID_HOOKS ((1 << NF_IP6_LOCAL_IN) | (1 << NF_IP6_FORWARD) | (1 << NF_IP6_LOCAL_OUT)) 20#define FILTER_VALID_HOOKS ((1 << NF_IP6_LOCAL_IN) | (1 << NF_IP6_FORWARD) | (1 << NF_IP6_LOCAL_OUT))
21 21
22/* Standard entry. */
23struct ip6t_standard
24{
25 struct ip6t_entry entry;
26 struct ip6t_standard_target target;
27};
28
29struct ip6t_error_target
30{
31 struct ip6t_entry_target target;
32 char errorname[IP6T_FUNCTION_MAXNAMELEN];
33};
34
35struct ip6t_error
36{
37 struct ip6t_entry entry;
38 struct ip6t_error_target target;
39};
40
41static struct 22static struct
42{ 23{
43 struct ip6t_replace repl; 24 struct ip6t_replace repl;
@@ -92,7 +73,7 @@ static struct
92 } 73 }
93}; 74};
94 75
95static struct ip6t_table packet_filter = { 76static struct xt_table packet_filter = {
96 .name = "filter", 77 .name = "filter",
97 .valid_hooks = FILTER_VALID_HOOKS, 78 .valid_hooks = FILTER_VALID_HOOKS,
98 .lock = RW_LOCK_UNLOCKED, 79 .lock = RW_LOCK_UNLOCKED,
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index 6250e86a6ddc..0c468d35a937 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -29,25 +29,6 @@ MODULE_DESCRIPTION("ip6tables mangle table");
29#define DEBUGP(x, args...) 29#define DEBUGP(x, args...)
30#endif 30#endif
31 31
32/* Standard entry. */
33struct ip6t_standard
34{
35 struct ip6t_entry entry;
36 struct ip6t_standard_target target;
37};
38
39struct ip6t_error_target
40{
41 struct ip6t_entry_target target;
42 char errorname[IP6T_FUNCTION_MAXNAMELEN];
43};
44
45struct ip6t_error
46{
47 struct ip6t_entry entry;
48 struct ip6t_error_target target;
49};
50
51static struct 32static struct
52{ 33{
53 struct ip6t_replace repl; 34 struct ip6t_replace repl;
@@ -69,7 +50,7 @@ static struct
69 0, NULL, { } }, 50 0, NULL, { } },
70 { 51 {
71 /* PRE_ROUTING */ 52 /* PRE_ROUTING */
72 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 53 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
73 0, 54 0,
74 sizeof(struct ip6t_entry), 55 sizeof(struct ip6t_entry),
75 sizeof(struct ip6t_standard), 56 sizeof(struct ip6t_standard),
@@ -77,7 +58,7 @@ static struct
77 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, 58 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
78 -NF_ACCEPT - 1 } }, 59 -NF_ACCEPT - 1 } },
79 /* LOCAL_IN */ 60 /* LOCAL_IN */
80 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 61 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
81 0, 62 0,
82 sizeof(struct ip6t_entry), 63 sizeof(struct ip6t_entry),
83 sizeof(struct ip6t_standard), 64 sizeof(struct ip6t_standard),
@@ -85,7 +66,7 @@ static struct
85 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, 66 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
86 -NF_ACCEPT - 1 } }, 67 -NF_ACCEPT - 1 } },
87 /* FORWARD */ 68 /* FORWARD */
88 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 69 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
89 0, 70 0,
90 sizeof(struct ip6t_entry), 71 sizeof(struct ip6t_entry),
91 sizeof(struct ip6t_standard), 72 sizeof(struct ip6t_standard),
@@ -93,7 +74,7 @@ static struct
93 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, 74 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
94 -NF_ACCEPT - 1 } }, 75 -NF_ACCEPT - 1 } },
95 /* LOCAL_OUT */ 76 /* LOCAL_OUT */
96 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 77 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
97 0, 78 0,
98 sizeof(struct ip6t_entry), 79 sizeof(struct ip6t_entry),
99 sizeof(struct ip6t_standard), 80 sizeof(struct ip6t_standard),
@@ -122,7 +103,7 @@ static struct
122 } 103 }
123}; 104};
124 105
125static struct ip6t_table packet_mangler = { 106static struct xt_table packet_mangler = {
126 .name = "mangle", 107 .name = "mangle",
127 .valid_hooks = MANGLE_VALID_HOOKS, 108 .valid_hooks = MANGLE_VALID_HOOKS,
128 .lock = RW_LOCK_UNLOCKED, 109 .lock = RW_LOCK_UNLOCKED,
@@ -175,7 +156,7 @@ ip6t_local_hook(unsigned int hook,
175 156
176 ret = ip6t_do_table(pskb, hook, in, out, &packet_mangler); 157 ret = ip6t_do_table(pskb, hook, in, out, &packet_mangler);
177 158
178 if (ret != NF_DROP && ret != NF_STOLEN 159 if (ret != NF_DROP && ret != NF_STOLEN
179 && (memcmp(&(*pskb)->nh.ipv6h->saddr, &saddr, sizeof(saddr)) 160 && (memcmp(&(*pskb)->nh.ipv6h->saddr, &saddr, sizeof(saddr))
180 || memcmp(&(*pskb)->nh.ipv6h->daddr, &daddr, sizeof(daddr)) 161 || memcmp(&(*pskb)->nh.ipv6h->daddr, &daddr, sizeof(daddr))
181 || (*pskb)->mark != mark 162 || (*pskb)->mark != mark
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index b4154da575c0..a3eb5b8ce18d 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -14,25 +14,6 @@
14#define DEBUGP(x, args...) 14#define DEBUGP(x, args...)
15#endif 15#endif
16 16
17/* Standard entry. */
18struct ip6t_standard
19{
20 struct ip6t_entry entry;
21 struct ip6t_standard_target target;
22};
23
24struct ip6t_error_target
25{
26 struct ip6t_entry_target target;
27 char errorname[IP6T_FUNCTION_MAXNAMELEN];
28};
29
30struct ip6t_error
31{
32 struct ip6t_entry entry;
33 struct ip6t_error_target target;
34};
35
36static struct 17static struct
37{ 18{
38 struct ip6t_replace repl; 19 struct ip6t_replace repl;
@@ -106,10 +87,10 @@ static struct
106 } 87 }
107}; 88};
108 89
109static struct xt_table packet_raw = { 90static struct xt_table packet_raw = {
110 .name = "raw", 91 .name = "raw",
111 .valid_hooks = RAW_VALID_HOOKS, 92 .valid_hooks = RAW_VALID_HOOKS,
112 .lock = RW_LOCK_UNLOCKED, 93 .lock = RW_LOCK_UNLOCKED,
113 .me = THIS_MODULE, 94 .me = THIS_MODULE,
114 .af = AF_INET6, 95 .af = AF_INET6,
115}; 96};
@@ -125,17 +106,17 @@ ip6t_hook(unsigned int hook,
125 return ip6t_do_table(pskb, hook, in, out, &packet_raw); 106 return ip6t_do_table(pskb, hook, in, out, &packet_raw);
126} 107}
127 108
128static struct nf_hook_ops ip6t_ops[] = { 109static struct nf_hook_ops ip6t_ops[] = {
129 { 110 {
130 .hook = ip6t_hook, 111 .hook = ip6t_hook,
131 .pf = PF_INET6, 112 .pf = PF_INET6,
132 .hooknum = NF_IP6_PRE_ROUTING, 113 .hooknum = NF_IP6_PRE_ROUTING,
133 .priority = NF_IP6_PRI_FIRST, 114 .priority = NF_IP6_PRI_FIRST,
134 .owner = THIS_MODULE, 115 .owner = THIS_MODULE,
135 }, 116 },
136 { 117 {
137 .hook = ip6t_hook, 118 .hook = ip6t_hook,
138 .pf = PF_INET6, 119 .pf = PF_INET6,
139 .hooknum = NF_IP6_LOCAL_OUT, 120 .hooknum = NF_IP6_LOCAL_OUT,
140 .priority = NF_IP6_PRI_FIRST, 121 .priority = NF_IP6_PRI_FIRST,
141 .owner = THIS_MODULE, 122 .owner = THIS_MODULE,
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index a20615ffccff..4b7be4bb4d03 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -154,8 +154,8 @@ ipv6_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
154 */ 154 */
155 if ((protoff < 0) || (protoff > (*pskb)->len)) { 155 if ((protoff < 0) || (protoff > (*pskb)->len)) {
156 DEBUGP("ip6_conntrack_core: can't find proto in pkt\n"); 156 DEBUGP("ip6_conntrack_core: can't find proto in pkt\n");
157 NF_CT_STAT_INC(error); 157 NF_CT_STAT_INC_ATOMIC(error);
158 NF_CT_STAT_INC(invalid); 158 NF_CT_STAT_INC_ATOMIC(invalid);
159 return -NF_ACCEPT; 159 return -NF_ACCEPT;
160 } 160 }
161 161
@@ -349,7 +349,7 @@ static ctl_table nf_ct_ipv6_sysctl_table[] = {
349 .mode = 0644, 349 .mode = 0644,
350 .proc_handler = &proc_dointvec, 350 .proc_handler = &proc_dointvec,
351 }, 351 },
352 { .ctl_name = 0 } 352 { .ctl_name = 0 }
353}; 353};
354#endif 354#endif
355 355
@@ -386,7 +386,7 @@ static int ipv6_nfattr_to_tuple(struct nfattr *tb[],
386 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) 386 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
387 return -EINVAL; 387 return -EINVAL;
388 388
389 memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]), 389 memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]),
390 sizeof(u_int32_t) * 4); 390 sizeof(u_int32_t) * 4);
391 memcpy(&t->dst.u3.ip6, NFA_DATA(tb[CTA_IP_V6_DST-1]), 391 memcpy(&t->dst.u3.ip6, NFA_DATA(tb[CTA_IP_V6_DST-1]),
392 sizeof(u_int32_t) * 4); 392 sizeof(u_int32_t) * 4);
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 3905cacc69af..19bdb7cb8ff3 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -104,9 +104,9 @@ static int icmpv6_packet(struct nf_conn *ct,
104 unsigned int hooknum) 104 unsigned int hooknum)
105{ 105{
106 /* Try to delete connection immediately after all replies: 106 /* Try to delete connection immediately after all replies:
107 won't actually vanish as we still have skb, and del_timer 107 won't actually vanish as we still have skb, and del_timer
108 means this will only run once even if count hits zero twice 108 means this will only run once even if count hits zero twice
109 (theoretically possible with SMP) */ 109 (theoretically possible with SMP) */
110 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) { 110 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
111 if (atomic_dec_and_test(&ct->proto.icmp.count) 111 if (atomic_dec_and_test(&ct->proto.icmp.count)
112 && del_timer(&ct->timeout)) 112 && del_timer(&ct->timeout))
@@ -182,6 +182,7 @@ icmpv6_error_message(struct sk_buff *skb,
182 return -NF_ACCEPT; 182 return -NF_ACCEPT;
183 } 183 }
184 184
185 /* rcu_read_lock()ed by nf_hook_slow */
185 inproto = __nf_ct_l4proto_find(PF_INET6, inprotonum); 186 inproto = __nf_ct_l4proto_find(PF_INET6, inprotonum);
186 187
187 /* Are they talking about one of our connections? */ 188 /* Are they talking about one of our connections? */
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index d9c15402ba66..15ab1e3e8b56 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -311,7 +311,7 @@ static struct nf_ct_frag6_queue *nf_ct_frag6_intern(unsigned int hash,
311 write_lock(&nf_ct_frag6_lock); 311 write_lock(&nf_ct_frag6_lock);
312#ifdef CONFIG_SMP 312#ifdef CONFIG_SMP
313 hlist_for_each_entry(fq, n, &nf_ct_frag6_hash[hash], list) { 313 hlist_for_each_entry(fq, n, &nf_ct_frag6_hash[hash], list) {
314 if (fq->id == fq_in->id && 314 if (fq->id == fq_in->id &&
315 ipv6_addr_equal(&fq_in->saddr, &fq->saddr) && 315 ipv6_addr_equal(&fq_in->saddr, &fq->saddr) &&
316 ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) { 316 ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) {
317 atomic_inc(&fq->refcnt); 317 atomic_inc(&fq->refcnt);
@@ -374,7 +374,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
374 374
375 read_lock(&nf_ct_frag6_lock); 375 read_lock(&nf_ct_frag6_lock);
376 hlist_for_each_entry(fq, n, &nf_ct_frag6_hash[hash], list) { 376 hlist_for_each_entry(fq, n, &nf_ct_frag6_hash[hash], list) {
377 if (fq->id == id && 377 if (fq->id == id &&
378 ipv6_addr_equal(src, &fq->saddr) && 378 ipv6_addr_equal(src, &fq->saddr) &&
379 ipv6_addr_equal(dst, &fq->daddr)) { 379 ipv6_addr_equal(dst, &fq->daddr)) {
380 atomic_inc(&fq->refcnt); 380 atomic_inc(&fq->refcnt);
@@ -388,7 +388,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
388} 388}
389 389
390 390
391static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb, 391static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
392 struct frag_hdr *fhdr, int nhoff) 392 struct frag_hdr *fhdr, int nhoff)
393{ 393{
394 struct sk_buff *prev, *next; 394 struct sk_buff *prev, *next;
@@ -405,12 +405,12 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
405 405
406 if ((unsigned int)end > IPV6_MAXPLEN) { 406 if ((unsigned int)end > IPV6_MAXPLEN) {
407 DEBUGP("offset is too large.\n"); 407 DEBUGP("offset is too large.\n");
408 return -1; 408 return -1;
409 } 409 }
410 410
411 if (skb->ip_summed == CHECKSUM_COMPLETE) 411 if (skb->ip_summed == CHECKSUM_COMPLETE)
412 skb->csum = csum_sub(skb->csum, 412 skb->csum = csum_sub(skb->csum,
413 csum_partial(skb->nh.raw, 413 csum_partial(skb->nh.raw,
414 (u8*)(fhdr + 1) - skb->nh.raw, 414 (u8*)(fhdr + 1) - skb->nh.raw,
415 0)); 415 0));
416 416
@@ -625,7 +625,7 @@ nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
625 /* We have to remove fragment header from datagram and to relocate 625 /* We have to remove fragment header from datagram and to relocate
626 * header in order to calculate ICV correctly. */ 626 * header in order to calculate ICV correctly. */
627 head->nh.raw[fq->nhoffset] = head->h.raw[0]; 627 head->nh.raw[fq->nhoffset] = head->h.raw[0];
628 memmove(head->head + sizeof(struct frag_hdr), head->head, 628 memmove(head->head + sizeof(struct frag_hdr), head->head,
629 (head->data - head->head) - sizeof(struct frag_hdr)); 629 (head->data - head->head) - sizeof(struct frag_hdr));
630 head->mac.raw += sizeof(struct frag_hdr); 630 head->mac.raw += sizeof(struct frag_hdr);
631 head->nh.raw += sizeof(struct frag_hdr); 631 head->nh.raw += sizeof(struct frag_hdr);
@@ -701,41 +701,41 @@ out_fail:
701static int 701static int
702find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff) 702find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
703{ 703{
704 u8 nexthdr = skb->nh.ipv6h->nexthdr; 704 u8 nexthdr = skb->nh.ipv6h->nexthdr;
705 u8 prev_nhoff = (u8 *)&skb->nh.ipv6h->nexthdr - skb->data; 705 u8 prev_nhoff = (u8 *)&skb->nh.ipv6h->nexthdr - skb->data;
706 int start = (u8 *)(skb->nh.ipv6h+1) - skb->data; 706 int start = (u8 *)(skb->nh.ipv6h+1) - skb->data;
707 int len = skb->len - start; 707 int len = skb->len - start;
708 u8 prevhdr = NEXTHDR_IPV6; 708 u8 prevhdr = NEXTHDR_IPV6;
709 709
710 while (nexthdr != NEXTHDR_FRAGMENT) { 710 while (nexthdr != NEXTHDR_FRAGMENT) {
711 struct ipv6_opt_hdr hdr; 711 struct ipv6_opt_hdr hdr;
712 int hdrlen; 712 int hdrlen;
713 713
714 if (!ipv6_ext_hdr(nexthdr)) { 714 if (!ipv6_ext_hdr(nexthdr)) {
715 return -1; 715 return -1;
716 } 716 }
717 if (len < (int)sizeof(struct ipv6_opt_hdr)) { 717 if (len < (int)sizeof(struct ipv6_opt_hdr)) {
718 DEBUGP("too short\n"); 718 DEBUGP("too short\n");
719 return -1; 719 return -1;
720 } 720 }
721 if (nexthdr == NEXTHDR_NONE) { 721 if (nexthdr == NEXTHDR_NONE) {
722 DEBUGP("next header is none\n"); 722 DEBUGP("next header is none\n");
723 return -1; 723 return -1;
724 } 724 }
725 if (skb_copy_bits(skb, start, &hdr, sizeof(hdr))) 725 if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
726 BUG(); 726 BUG();
727 if (nexthdr == NEXTHDR_AUTH) 727 if (nexthdr == NEXTHDR_AUTH)
728 hdrlen = (hdr.hdrlen+2)<<2; 728 hdrlen = (hdr.hdrlen+2)<<2;
729 else 729 else
730 hdrlen = ipv6_optlen(&hdr); 730 hdrlen = ipv6_optlen(&hdr);
731 731
732 prevhdr = nexthdr; 732 prevhdr = nexthdr;
733 prev_nhoff = start; 733 prev_nhoff = start;
734 734
735 nexthdr = hdr.nexthdr; 735 nexthdr = hdr.nexthdr;
736 len -= hdrlen; 736 len -= hdrlen;
737 start += hdrlen; 737 start += hdrlen;
738 } 738 }
739 739
740 if (len < 0) 740 if (len < 0)
741 return -1; 741 return -1;
@@ -749,7 +749,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
749 749
750struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb) 750struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
751{ 751{
752 struct sk_buff *clone; 752 struct sk_buff *clone;
753 struct net_device *dev = skb->dev; 753 struct net_device *dev = skb->dev;
754 struct frag_hdr *fhdr; 754 struct frag_hdr *fhdr;
755 struct nf_ct_frag6_queue *fq; 755 struct nf_ct_frag6_queue *fq;
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 35249d8487bb..c82257dd04b6 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -50,7 +50,7 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
50 seq_printf(seq, "UDP6: inuse %d\n", 50 seq_printf(seq, "UDP6: inuse %d\n",
51 fold_prot_inuse(&udpv6_prot)); 51 fold_prot_inuse(&udpv6_prot));
52 seq_printf(seq, "UDPLITE6: inuse %d\n", 52 seq_printf(seq, "UDPLITE6: inuse %d\n",
53 fold_prot_inuse(&udplitev6_prot)); 53 fold_prot_inuse(&udplitev6_prot));
54 seq_printf(seq, "RAW6: inuse %d\n", 54 seq_printf(seq, "RAW6: inuse %d\n",
55 fold_prot_inuse(&rawv6_prot)); 55 fold_prot_inuse(&rawv6_prot));
56 seq_printf(seq, "FRAG6: inuse %d memory %d\n", 56 seq_printf(seq, "FRAG6: inuse %d memory %d\n",
@@ -89,7 +89,7 @@ static struct snmp_mib snmp6_icmp6_list[] = {
89/* icmpv6 mib according to RFC 2466 89/* icmpv6 mib according to RFC 2466
90 90
91 Exceptions: {In|Out}AdminProhibs are removed, because I see 91 Exceptions: {In|Out}AdminProhibs are removed, because I see
92 no good reasons to account them separately 92 no good reasons to account them separately
93 of another dest.unreachs. 93 of another dest.unreachs.
94 OutErrs is zero identically. 94 OutErrs is zero identically.
95 OutEchos too. 95 OutEchos too.
@@ -146,14 +146,14 @@ static struct snmp_mib snmp6_udplite6_list[] = {
146static unsigned long 146static unsigned long
147fold_field(void *mib[], int offt) 147fold_field(void *mib[], int offt)
148{ 148{
149 unsigned long res = 0; 149 unsigned long res = 0;
150 int i; 150 int i;
151 151
152 for_each_possible_cpu(i) { 152 for_each_possible_cpu(i) {
153 res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt); 153 res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt);
154 res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt); 154 res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt);
155 } 155 }
156 return res; 156 return res;
157} 157}
158 158
159static inline void 159static inline void
@@ -161,7 +161,7 @@ snmp6_seq_show_item(struct seq_file *seq, void **mib, struct snmp_mib *itemlist)
161{ 161{
162 int i; 162 int i;
163 for (i=0; itemlist[i].name; i++) 163 for (i=0; itemlist[i].name; i++)
164 seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name, 164 seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name,
165 fold_field(mib, itemlist[i].entry)); 165 fold_field(mib, itemlist[i].entry));
166} 166}
167 167
@@ -187,7 +187,7 @@ static int sockstat6_seq_open(struct inode *inode, struct file *file)
187 return single_open(file, sockstat6_seq_show, NULL); 187 return single_open(file, sockstat6_seq_show, NULL);
188} 188}
189 189
190static struct file_operations sockstat6_seq_fops = { 190static const struct file_operations sockstat6_seq_fops = {
191 .owner = THIS_MODULE, 191 .owner = THIS_MODULE,
192 .open = sockstat6_seq_open, 192 .open = sockstat6_seq_open,
193 .read = seq_read, 193 .read = seq_read,
@@ -200,7 +200,7 @@ static int snmp6_seq_open(struct inode *inode, struct file *file)
200 return single_open(file, snmp6_seq_show, PDE(inode)->data); 200 return single_open(file, snmp6_seq_show, PDE(inode)->data);
201} 201}
202 202
203static struct file_operations snmp6_seq_fops = { 203static const struct file_operations snmp6_seq_fops = {
204 .owner = THIS_MODULE, 204 .owner = THIS_MODULE,
205 .open = snmp6_seq_open, 205 .open = snmp6_seq_open,
206 .read = seq_read, 206 .read = seq_read,
diff --git a/net/ipv6/protocol.c b/net/ipv6/protocol.c
index 52c1d58b6ca6..ad0410c99675 100644
--- a/net/ipv6/protocol.c
+++ b/net/ipv6/protocol.c
@@ -64,7 +64,7 @@ int inet6_add_protocol(struct inet6_protocol *prot, unsigned char protocol)
64/* 64/*
65 * Remove a protocol from the hash tables. 65 * Remove a protocol from the hash tables.
66 */ 66 */
67 67
68int inet6_del_protocol(struct inet6_protocol *prot, unsigned char protocol) 68int inet6_del_protocol(struct inet6_protocol *prot, unsigned char protocol)
69{ 69{
70 int ret, hash = protocol & (MAX_INET_PROTOS - 1); 70 int ret, hash = protocol & (MAX_INET_PROTOS - 1);
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 4ae1b19ada5d..1f8f6275a7e4 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * RAW sockets for IPv6 2 * RAW sockets for IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * Adapted from linux/net/ipv4/raw.c 8 * Adapted from linux/net/ipv4/raw.c
9 * 9 *
@@ -11,7 +11,7 @@
11 * 11 *
12 * Fixes: 12 * Fixes:
13 * Hideaki YOSHIFUJI : sin6_scope_id support 13 * Hideaki YOSHIFUJI : sin6_scope_id support
14 * YOSHIFUJI,H.@USAGI : raw checksum (RFC2292(bis) compliance) 14 * YOSHIFUJI,H.@USAGI : raw checksum (RFC2292(bis) compliance)
15 * Kazunori MIYAZAWA @USAGI: change process style to use ip6_append_data 15 * Kazunori MIYAZAWA @USAGI: change process style to use ip6_append_data
16 * 16 *
17 * This program is free software; you can redistribute it and/or 17 * This program is free software; you can redistribute it and/or
@@ -71,12 +71,12 @@ static void raw_v6_hash(struct sock *sk)
71 write_lock_bh(&raw_v6_lock); 71 write_lock_bh(&raw_v6_lock);
72 sk_add_node(sk, list); 72 sk_add_node(sk, list);
73 sock_prot_inc_use(sk->sk_prot); 73 sock_prot_inc_use(sk->sk_prot);
74 write_unlock_bh(&raw_v6_lock); 74 write_unlock_bh(&raw_v6_lock);
75} 75}
76 76
77static void raw_v6_unhash(struct sock *sk) 77static void raw_v6_unhash(struct sock *sk)
78{ 78{
79 write_lock_bh(&raw_v6_lock); 79 write_lock_bh(&raw_v6_lock);
80 if (sk_del_node_init(sk)) 80 if (sk_del_node_init(sk))
81 sock_prot_dec_use(sk->sk_prot); 81 sock_prot_dec_use(sk->sk_prot);
82 write_unlock_bh(&raw_v6_lock); 82 write_unlock_bh(&raw_v6_lock);
@@ -250,7 +250,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
250 */ 250 */
251 sk->sk_bound_dev_if = addr->sin6_scope_id; 251 sk->sk_bound_dev_if = addr->sin6_scope_id;
252 } 252 }
253 253
254 /* Binding to link-local address requires an interface */ 254 /* Binding to link-local address requires an interface */
255 if (!sk->sk_bound_dev_if) 255 if (!sk->sk_bound_dev_if)
256 goto out; 256 goto out;
@@ -261,7 +261,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
261 goto out; 261 goto out;
262 } 262 }
263 } 263 }
264 264
265 /* ipv4 addr of the socket is invalid. Only the 265 /* ipv4 addr of the socket is invalid. Only the
266 * unspecified and mapped address have a v4 equivalent. 266 * unspecified and mapped address have a v4 equivalent.
267 */ 267 */
@@ -324,7 +324,7 @@ void rawv6_err(struct sock *sk, struct sk_buff *skb,
324 324
325static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb) 325static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
326{ 326{
327 if ((raw6_sk(sk)->checksum || sk->sk_filter) && 327 if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
328 skb_checksum_complete(skb)) { 328 skb_checksum_complete(skb)) {
329 /* FIXME: increment a raw6 drops counter here */ 329 /* FIXME: increment a raw6 drops counter here */
330 kfree_skb(skb); 330 kfree_skb(skb);
@@ -342,10 +342,10 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
342} 342}
343 343
344/* 344/*
345 * This is next to useless... 345 * This is next to useless...
346 * if we demultiplex in network layer we don't need the extra call 346 * if we demultiplex in network layer we don't need the extra call
347 * just to queue the skb... 347 * just to queue the skb...
348 * maybe we could have the network decide upon a hint if it 348 * maybe we could have the network decide upon a hint if it
349 * should call raw_rcv for demultiplexing 349 * should call raw_rcv for demultiplexing
350 */ 350 */
351int rawv6_rcv(struct sock *sk, struct sk_buff *skb) 351int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
@@ -353,17 +353,17 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
353 struct inet_sock *inet = inet_sk(sk); 353 struct inet_sock *inet = inet_sk(sk);
354 struct raw6_sock *rp = raw6_sk(sk); 354 struct raw6_sock *rp = raw6_sk(sk);
355 355
356 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { 356 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
357 kfree_skb(skb); 357 kfree_skb(skb);
358 return NET_RX_DROP; 358 return NET_RX_DROP;
359 } 359 }
360 360
361 if (!rp->checksum) 361 if (!rp->checksum)
362 skb->ip_summed = CHECKSUM_UNNECESSARY; 362 skb->ip_summed = CHECKSUM_UNNECESSARY;
363 363
364 if (skb->ip_summed == CHECKSUM_COMPLETE) { 364 if (skb->ip_summed == CHECKSUM_COMPLETE) {
365 skb_postpull_rcsum(skb, skb->nh.raw, 365 skb_postpull_rcsum(skb, skb->nh.raw,
366 skb->h.raw - skb->nh.raw); 366 skb->h.raw - skb->nh.raw);
367 if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr, 367 if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr,
368 &skb->nh.ipv6h->daddr, 368 &skb->nh.ipv6h->daddr,
369 skb->len, inet->num, skb->csum)) 369 skb->len, inet->num, skb->csum))
@@ -404,8 +404,8 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
404 404
405 if (flags & MSG_OOB) 405 if (flags & MSG_OOB)
406 return -EOPNOTSUPP; 406 return -EOPNOTSUPP;
407 407
408 if (addr_len) 408 if (addr_len)
409 *addr_len=sizeof(*sin6); 409 *addr_len=sizeof(*sin6);
410 410
411 if (flags & MSG_ERRQUEUE) 411 if (flags & MSG_ERRQUEUE)
@@ -416,10 +416,10 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
416 goto out; 416 goto out;
417 417
418 copied = skb->len; 418 copied = skb->len;
419 if (copied > len) { 419 if (copied > len) {
420 copied = len; 420 copied = len;
421 msg->msg_flags |= MSG_TRUNC; 421 msg->msg_flags |= MSG_TRUNC;
422 } 422 }
423 423
424 if (skb->ip_summed==CHECKSUM_UNNECESSARY) { 424 if (skb->ip_summed==CHECKSUM_UNNECESSARY) {
425 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); 425 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
@@ -549,7 +549,7 @@ out:
549} 549}
550 550
551static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, 551static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
552 struct flowi *fl, struct rt6_info *rt, 552 struct flowi *fl, struct rt6_info *rt,
553 unsigned int flags) 553 unsigned int flags)
554{ 554{
555 struct ipv6_pinfo *np = inet6_sk(sk); 555 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -570,7 +570,7 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
570 skb = sock_alloc_send_skb(sk, length+hh_len+15, 570 skb = sock_alloc_send_skb(sk, length+hh_len+15,
571 flags&MSG_DONTWAIT, &err); 571 flags&MSG_DONTWAIT, &err);
572 if (skb == NULL) 572 if (skb == NULL)
573 goto error; 573 goto error;
574 skb_reserve(skb, hh_len); 574 skb_reserve(skb, hh_len);
575 575
576 skb->priority = sk->sk_priority; 576 skb->priority = sk->sk_priority;
@@ -600,7 +600,7 @@ error_fault:
600 kfree_skb(skb); 600 kfree_skb(skb);
601error: 601error:
602 IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS); 602 IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
603 return err; 603 return err;
604} 604}
605 605
606static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg) 606static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
@@ -694,19 +694,19 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
694 return -EMSGSIZE; 694 return -EMSGSIZE;
695 695
696 /* Mirror BSD error message compatibility */ 696 /* Mirror BSD error message compatibility */
697 if (msg->msg_flags & MSG_OOB) 697 if (msg->msg_flags & MSG_OOB)
698 return -EOPNOTSUPP; 698 return -EOPNOTSUPP;
699 699
700 /* 700 /*
701 * Get and verify the address. 701 * Get and verify the address.
702 */ 702 */
703 memset(&fl, 0, sizeof(fl)); 703 memset(&fl, 0, sizeof(fl));
704 704
705 if (sin6) { 705 if (sin6) {
706 if (addr_len < SIN6_LEN_RFC2133) 706 if (addr_len < SIN6_LEN_RFC2133)
707 return -EINVAL; 707 return -EINVAL;
708 708
709 if (sin6->sin6_family && sin6->sin6_family != AF_INET6) 709 if (sin6->sin6_family && sin6->sin6_family != AF_INET6)
710 return(-EAFNOSUPPORT); 710 return(-EAFNOSUPPORT);
711 711
712 /* port is the proto value [0..255] carried in nexthdr */ 712 /* port is the proto value [0..255] carried in nexthdr */
@@ -744,17 +744,17 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
744 ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL) 744 ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
745 fl.oif = sin6->sin6_scope_id; 745 fl.oif = sin6->sin6_scope_id;
746 } else { 746 } else {
747 if (sk->sk_state != TCP_ESTABLISHED) 747 if (sk->sk_state != TCP_ESTABLISHED)
748 return -EDESTADDRREQ; 748 return -EDESTADDRREQ;
749 749
750 proto = inet->num; 750 proto = inet->num;
751 daddr = &np->daddr; 751 daddr = &np->daddr;
752 fl.fl6_flowlabel = np->flow_label; 752 fl.fl6_flowlabel = np->flow_label;
753 } 753 }
754 754
755 if (ipv6_addr_any(daddr)) { 755 if (ipv6_addr_any(daddr)) {
756 /* 756 /*
757 * unspecified destination address 757 * unspecified destination address
758 * treated as error... is this correct ? 758 * treated as error... is this correct ?
759 */ 759 */
760 fl6_sock_release(flowlabel); 760 fl6_sock_release(flowlabel);
@@ -792,7 +792,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
792 err = rawv6_probe_proto_opt(&fl, msg); 792 err = rawv6_probe_proto_opt(&fl, msg);
793 if (err) 793 if (err)
794 goto out; 794 goto out;
795 795
796 ipv6_addr_copy(&fl.fl6_dst, daddr); 796 ipv6_addr_copy(&fl.fl6_dst, daddr);
797 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 797 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
798 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 798 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
@@ -815,7 +815,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
815 if (final_p) 815 if (final_p)
816 ipv6_addr_copy(&fl.fl6_dst, final_p); 816 ipv6_addr_copy(&fl.fl6_dst, final_p);
817 817
818 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) 818 if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
819 goto out; 819 goto out;
820 820
821 if (hlimit < 0) { 821 if (hlimit < 0) {
@@ -856,7 +856,7 @@ done:
856 dst_release(dst); 856 dst_release(dst);
857 if (!inet->hdrincl) 857 if (!inet->hdrincl)
858 release_sock(sk); 858 release_sock(sk);
859out: 859out:
860 fl6_sock_release(flowlabel); 860 fl6_sock_release(flowlabel);
861 return err<0?err:len; 861 return err<0?err:len;
862do_confirm: 862do_confirm:
@@ -867,7 +867,7 @@ do_confirm:
867 goto done; 867 goto done;
868} 868}
869 869
870static int rawv6_seticmpfilter(struct sock *sk, int level, int optname, 870static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
871 char __user *optval, int optlen) 871 char __user *optval, int optlen)
872{ 872{
873 switch (optname) { 873 switch (optname) {
@@ -884,7 +884,7 @@ static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
884 return 0; 884 return 0;
885} 885}
886 886
887static int rawv6_geticmpfilter(struct sock *sk, int level, int optname, 887static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
888 char __user *optval, int __user *optlen) 888 char __user *optval, int __user *optlen)
889{ 889{
890 int len; 890 int len;
@@ -916,7 +916,7 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname,
916 struct raw6_sock *rp = raw6_sk(sk); 916 struct raw6_sock *rp = raw6_sk(sk);
917 int val; 917 int val;
918 918
919 if (get_user(val, (int __user *)optval)) 919 if (get_user(val, (int __user *)optval))
920 return -EFAULT; 920 return -EFAULT;
921 921
922 switch (optname) { 922 switch (optname) {
@@ -1094,10 +1094,19 @@ static void rawv6_close(struct sock *sk, long timeout)
1094 1094
1095static int rawv6_init_sk(struct sock *sk) 1095static int rawv6_init_sk(struct sock *sk)
1096{ 1096{
1097 if (inet_sk(sk)->num == IPPROTO_ICMPV6) { 1097 struct raw6_sock *rp = raw6_sk(sk);
1098 struct raw6_sock *rp = raw6_sk(sk); 1098
1099 switch (inet_sk(sk)->num) {
1100 case IPPROTO_ICMPV6:
1099 rp->checksum = 1; 1101 rp->checksum = 1;
1100 rp->offset = 2; 1102 rp->offset = 2;
1103 break;
1104 case IPPROTO_MH:
1105 rp->checksum = 1;
1106 rp->offset = 4;
1107 break;
1108 default:
1109 break;
1101 } 1110 }
1102 return(0); 1111 return(0);
1103} 1112}
@@ -1215,7 +1224,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
1215 src->s6_addr32[2], src->s6_addr32[3], srcp, 1224 src->s6_addr32[2], src->s6_addr32[3], srcp,
1216 dest->s6_addr32[0], dest->s6_addr32[1], 1225 dest->s6_addr32[0], dest->s6_addr32[1],
1217 dest->s6_addr32[2], dest->s6_addr32[3], destp, 1226 dest->s6_addr32[2], dest->s6_addr32[3], destp,
1218 sp->sk_state, 1227 sp->sk_state,
1219 atomic_read(&sp->sk_wmem_alloc), 1228 atomic_read(&sp->sk_wmem_alloc),
1220 atomic_read(&sp->sk_rmem_alloc), 1229 atomic_read(&sp->sk_rmem_alloc),
1221 0, 0L, 0, 1230 0, 0L, 0,
@@ -1264,7 +1273,7 @@ out_kfree:
1264 goto out; 1273 goto out;
1265} 1274}
1266 1275
1267static struct file_operations raw6_seq_fops = { 1276static const struct file_operations raw6_seq_fops = {
1268 .owner = THIS_MODULE, 1277 .owner = THIS_MODULE,
1269 .open = raw6_seq_open, 1278 .open = raw6_seq_open,
1270 .read = seq_read, 1279 .read = seq_read,
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 6f9a9046510f..7034c54e5010 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * IPv6 fragment reassembly 2 * IPv6 fragment reassembly
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: reassembly.c,v 1.26 2001/03/07 22:00:57 davem Exp $ 8 * $Id: reassembly.c,v 1.26 2001/03/07 22:00:57 davem Exp $
9 * 9 *
@@ -15,8 +15,8 @@
15 * 2 of the License, or (at your option) any later version. 15 * 2 of the License, or (at your option) any later version.
16 */ 16 */
17 17
18/* 18/*
19 * Fixes: 19 * Fixes:
20 * Andi Kleen Make it work with multiple hosts. 20 * Andi Kleen Make it work with multiple hosts.
21 * More RFC compliance. 21 * More RFC compliance.
22 * 22 *
@@ -343,7 +343,7 @@ static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in)
343 hash = ip6qhashfn(fq_in->id, &fq_in->saddr, &fq_in->daddr); 343 hash = ip6qhashfn(fq_in->id, &fq_in->saddr, &fq_in->daddr);
344#ifdef CONFIG_SMP 344#ifdef CONFIG_SMP
345 hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) { 345 hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) {
346 if (fq->id == fq_in->id && 346 if (fq->id == fq_in->id &&
347 ipv6_addr_equal(&fq_in->saddr, &fq->saddr) && 347 ipv6_addr_equal(&fq_in->saddr, &fq->saddr) &&
348 ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) { 348 ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) {
349 atomic_inc(&fq->refcnt); 349 atomic_inc(&fq->refcnt);
@@ -406,7 +406,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst,
406 read_lock(&ip6_frag_lock); 406 read_lock(&ip6_frag_lock);
407 hash = ip6qhashfn(id, src, dst); 407 hash = ip6qhashfn(id, src, dst);
408 hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) { 408 hlist_for_each_entry(fq, n, &ip6_frag_hash[hash], list) {
409 if (fq->id == id && 409 if (fq->id == id &&
410 ipv6_addr_equal(src, &fq->saddr) && 410 ipv6_addr_equal(src, &fq->saddr) &&
411 ipv6_addr_equal(dst, &fq->daddr)) { 411 ipv6_addr_equal(dst, &fq->daddr)) {
412 atomic_inc(&fq->refcnt); 412 atomic_inc(&fq->refcnt);
@@ -420,7 +420,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst,
420} 420}
421 421
422 422
423static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, 423static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
424 struct frag_hdr *fhdr, int nhoff) 424 struct frag_hdr *fhdr, int nhoff)
425{ 425{
426 struct sk_buff *prev, *next; 426 struct sk_buff *prev, *next;
@@ -436,13 +436,13 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
436 if ((unsigned int)end > IPV6_MAXPLEN) { 436 if ((unsigned int)end > IPV6_MAXPLEN) {
437 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), 437 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
438 IPSTATS_MIB_INHDRERRORS); 438 IPSTATS_MIB_INHDRERRORS);
439 icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw); 439 icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw);
440 return; 440 return;
441 } 441 }
442 442
443 if (skb->ip_summed == CHECKSUM_COMPLETE) 443 if (skb->ip_summed == CHECKSUM_COMPLETE)
444 skb->csum = csum_sub(skb->csum, 444 skb->csum = csum_sub(skb->csum,
445 csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0)); 445 csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0));
446 446
447 /* Is this the final fragment? */ 447 /* Is this the final fragment? */
448 if (!(fhdr->frag_off & htons(IP6_MF))) { 448 if (!(fhdr->frag_off & htons(IP6_MF))) {
@@ -464,7 +464,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
464 */ 464 */
465 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), 465 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
466 IPSTATS_MIB_INHDRERRORS); 466 IPSTATS_MIB_INHDRERRORS);
467 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, 467 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
468 offsetof(struct ipv6hdr, payload_len)); 468 offsetof(struct ipv6hdr, payload_len));
469 return; 469 return;
470 } 470 }
@@ -482,7 +482,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
482 /* Point into the IP datagram 'data' part. */ 482 /* Point into the IP datagram 'data' part. */
483 if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) 483 if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data))
484 goto err; 484 goto err;
485 485
486 if (pskb_trim_rcsum(skb, end - offset)) 486 if (pskb_trim_rcsum(skb, end - offset))
487 goto err; 487 goto err;
488 488
@@ -640,7 +640,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in,
640 * header in order to calculate ICV correctly. */ 640 * header in order to calculate ICV correctly. */
641 nhoff = fq->nhoffset; 641 nhoff = fq->nhoffset;
642 head->nh.raw[nhoff] = head->h.raw[0]; 642 head->nh.raw[nhoff] = head->h.raw[0];
643 memmove(head->head + sizeof(struct frag_hdr), head->head, 643 memmove(head->head + sizeof(struct frag_hdr), head->head,
644 (head->data - head->head) - sizeof(struct frag_hdr)); 644 (head->data - head->head) - sizeof(struct frag_hdr));
645 head->mac.raw += sizeof(struct frag_hdr); 645 head->mac.raw += sizeof(struct frag_hdr);
646 head->nh.raw += sizeof(struct frag_hdr); 646 head->nh.raw += sizeof(struct frag_hdr);
@@ -695,7 +695,7 @@ out_fail:
695 695
696static int ipv6_frag_rcv(struct sk_buff **skbp) 696static int ipv6_frag_rcv(struct sk_buff **skbp)
697{ 697{
698 struct sk_buff *skb = *skbp; 698 struct sk_buff *skb = *skbp;
699 struct net_device *dev = skb->dev; 699 struct net_device *dev = skb->dev;
700 struct frag_hdr *fhdr; 700 struct frag_hdr *fhdr;
701 struct frag_queue *fq; 701 struct frag_queue *fq;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 5f0043c30b70..0e1f4b2cd3dd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3,7 +3,7 @@
3 * FIB front-end. 3 * FIB front-end.
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: route.c,v 1.56 2001/10/31 21:55:55 davem Exp $ 8 * $Id: route.c,v 1.56 2001/10/31 21:55:55 davem Exp $
9 * 9 *
@@ -201,7 +201,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)
201 if (idev != NULL) { 201 if (idev != NULL) {
202 rt->rt6i_idev = NULL; 202 rt->rt6i_idev = NULL;
203 in6_dev_put(idev); 203 in6_dev_put(idev);
204 } 204 }
205} 205}
206 206
207static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, 207static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
@@ -243,7 +243,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
243 struct rt6_info *sprt; 243 struct rt6_info *sprt;
244 244
245 if (oif) { 245 if (oif) {
246 for (sprt = rt; sprt; sprt = sprt->u.next) { 246 for (sprt = rt; sprt; sprt = sprt->u.dst.rt6_next) {
247 struct net_device *dev = sprt->rt6i_dev; 247 struct net_device *dev = sprt->rt6i_dev;
248 if (dev->ifindex == oif) 248 if (dev->ifindex == oif)
249 return sprt; 249 return sprt;
@@ -252,7 +252,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
252 sprt->rt6i_idev->dev->ifindex != oif) { 252 sprt->rt6i_idev->dev->ifindex != oif) {
253 if (strict && oif) 253 if (strict && oif)
254 continue; 254 continue;
255 if (local && (!oif || 255 if (local && (!oif ||
256 local->rt6i_idev->dev->ifindex == oif)) 256 local->rt6i_idev->dev->ifindex == oif))
257 continue; 257 continue;
258 } 258 }
@@ -311,12 +311,21 @@ static inline void rt6_probe(struct rt6_info *rt)
311static int inline rt6_check_dev(struct rt6_info *rt, int oif) 311static int inline rt6_check_dev(struct rt6_info *rt, int oif)
312{ 312{
313 struct net_device *dev = rt->rt6i_dev; 313 struct net_device *dev = rt->rt6i_dev;
314 if (!oif || dev->ifindex == oif) 314 int ret = 0;
315
316 if (!oif)
315 return 2; 317 return 2;
316 if ((dev->flags & IFF_LOOPBACK) && 318 if (dev->flags & IFF_LOOPBACK) {
317 rt->rt6i_idev && rt->rt6i_idev->dev->ifindex == oif) 319 if (!WARN_ON(rt->rt6i_idev == NULL) &&
318 return 1; 320 rt->rt6i_idev->dev->ifindex == oif)
319 return 0; 321 ret = 1;
322 else
323 return 0;
324 }
325 if (dev->ifindex == oif)
326 return 2;
327
328 return ret;
320} 329}
321 330
322static int inline rt6_check_neigh(struct rt6_info *rt) 331static int inline rt6_check_neigh(struct rt6_info *rt)
@@ -341,7 +350,7 @@ static int rt6_score_route(struct rt6_info *rt, int oif,
341 int strict) 350 int strict)
342{ 351{
343 int m, n; 352 int m, n;
344 353
345 m = rt6_check_dev(rt, oif); 354 m = rt6_check_dev(rt, oif);
346 if (!m && (strict & RT6_LOOKUP_F_IFACE)) 355 if (!m && (strict & RT6_LOOKUP_F_IFACE))
347 return -1; 356 return -1;
@@ -367,7 +376,7 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
367 376
368 for (rt = rt0, metric = rt0->rt6i_metric; 377 for (rt = rt0, metric = rt0->rt6i_metric;
369 rt && rt->rt6i_metric == metric && (!last || rt != rt0); 378 rt && rt->rt6i_metric == metric && (!last || rt != rt0);
370 rt = rt->u.next) { 379 rt = rt->u.dst.rt6_next) {
371 int m; 380 int m;
372 381
373 if (rt6_check_expired(rt)) 382 if (rt6_check_expired(rt))
@@ -395,9 +404,9 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
395 /* no entries matched; do round-robin */ 404 /* no entries matched; do round-robin */
396 static DEFINE_SPINLOCK(lock); 405 static DEFINE_SPINLOCK(lock);
397 spin_lock(&lock); 406 spin_lock(&lock);
398 *head = rt0->u.next; 407 *head = rt0->u.dst.rt6_next;
399 rt0->u.next = last->u.next; 408 rt0->u.dst.rt6_next = last->u.dst.rt6_next;
400 last->u.next = rt0; 409 last->u.dst.rt6_next = rt0;
401 spin_unlock(&lock); 410 spin_unlock(&lock);
402 } 411 }
403 412
@@ -714,7 +723,7 @@ void ip6_route_input(struct sk_buff *skb)
714 .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK, 723 .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
715 }, 724 },
716 }, 725 },
717 .mark = skb->mark, 726 .mark = skb->mark,
718 .proto = iph->nexthdr, 727 .proto = iph->nexthdr,
719 }; 728 };
720 729
@@ -879,9 +888,9 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
879 mtu = ip6_rt_min_advmss; 888 mtu = ip6_rt_min_advmss;
880 889
881 /* 890 /*
882 * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and 891 * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
883 * corresponding MSS is IPV6_MAXPLEN - tcp_header_size. 892 * corresponding MSS is IPV6_MAXPLEN - tcp_header_size.
884 * IPV6_MAXPLEN is also valid and means: "any MSS, 893 * IPV6_MAXPLEN is also valid and means: "any MSS,
885 * rely only on pmtu discovery" 894 * rely only on pmtu discovery"
886 */ 895 */
887 if (mtu > IPV6_MAXPLEN - sizeof(struct tcphdr)) 896 if (mtu > IPV6_MAXPLEN - sizeof(struct tcphdr))
@@ -892,7 +901,7 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
892static struct dst_entry *ndisc_dst_gc_list; 901static struct dst_entry *ndisc_dst_gc_list;
893static DEFINE_SPINLOCK(ndisc_lock); 902static DEFINE_SPINLOCK(ndisc_lock);
894 903
895struct dst_entry *ndisc_dst_alloc(struct net_device *dev, 904struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
896 struct neighbour *neigh, 905 struct neighbour *neigh,
897 struct in6_addr *addr, 906 struct in6_addr *addr,
898 int (*output)(struct sk_buff *)) 907 int (*output)(struct sk_buff *))
@@ -925,8 +934,8 @@ struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
925 rt->u.dst.output = output; 934 rt->u.dst.output = output;
926 935
927#if 0 /* there's no chance to use these for ndisc */ 936#if 0 /* there's no chance to use these for ndisc */
928 rt->u.dst.flags = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST 937 rt->u.dst.flags = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST
929 ? DST_HOST 938 ? DST_HOST
930 : 0; 939 : 0;
931 ipv6_addr_copy(&rt->rt6i_dst.addr, addr); 940 ipv6_addr_copy(&rt->rt6i_dst.addr, addr);
932 rt->rt6i_dst.plen = 128; 941 rt->rt6i_dst.plen = 128;
@@ -949,7 +958,7 @@ int ndisc_dst_gc(int *more)
949 int freed; 958 int freed;
950 959
951 next = NULL; 960 next = NULL;
952 freed = 0; 961 freed = 0;
953 962
954 spin_lock_bh(&ndisc_lock); 963 spin_lock_bh(&ndisc_lock);
955 pprev = &ndisc_dst_gc_list; 964 pprev = &ndisc_dst_gc_list;
@@ -1267,9 +1276,9 @@ static int ip6_route_del(struct fib6_config *cfg)
1267 fn = fib6_locate(&table->tb6_root, 1276 fn = fib6_locate(&table->tb6_root,
1268 &cfg->fc_dst, cfg->fc_dst_len, 1277 &cfg->fc_dst, cfg->fc_dst_len,
1269 &cfg->fc_src, cfg->fc_src_len); 1278 &cfg->fc_src, cfg->fc_src_len);
1270 1279
1271 if (fn) { 1280 if (fn) {
1272 for (rt = fn->leaf; rt; rt = rt->u.next) { 1281 for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
1273 if (cfg->fc_ifindex && 1282 if (cfg->fc_ifindex &&
1274 (rt->rt6i_dev == NULL || 1283 (rt->rt6i_dev == NULL ||
1275 rt->rt6i_dev->ifindex != cfg->fc_ifindex)) 1284 rt->rt6i_dev->ifindex != cfg->fc_ifindex))
@@ -1320,7 +1329,7 @@ static struct rt6_info *__ip6_route_redirect(struct fib6_table *table,
1320 read_lock_bh(&table->tb6_lock); 1329 read_lock_bh(&table->tb6_lock);
1321 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); 1330 fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
1322restart: 1331restart:
1323 for (rt = fn->leaf; rt; rt = rt->u.next) { 1332 for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
1324 /* 1333 /*
1325 * Current route is on-link; redirect is always invalid. 1334 * Current route is on-link; redirect is always invalid.
1326 * 1335 *
@@ -1396,7 +1405,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
1396 * We have finally decided to accept it. 1405 * We have finally decided to accept it.
1397 */ 1406 */
1398 1407
1399 neigh_update(neigh, lladdr, NUD_STALE, 1408 neigh_update(neigh, lladdr, NUD_STALE,
1400 NEIGH_UPDATE_F_WEAK_OVERRIDE| 1409 NEIGH_UPDATE_F_WEAK_OVERRIDE|
1401 NEIGH_UPDATE_F_OVERRIDE| 1410 NEIGH_UPDATE_F_OVERRIDE|
1402 (on_link ? 0 : (NEIGH_UPDATE_F_OVERRIDE_ISROUTER| 1411 (on_link ? 0 : (NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
@@ -1445,7 +1454,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
1445 } 1454 }
1446 1455
1447out: 1456out:
1448 dst_release(&rt->u.dst); 1457 dst_release(&rt->u.dst);
1449 return; 1458 return;
1450} 1459}
1451 1460
@@ -1469,7 +1478,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr,
1469 1478
1470 if (pmtu < IPV6_MIN_MTU) { 1479 if (pmtu < IPV6_MIN_MTU) {
1471 /* 1480 /*
1472 * According to RFC2460, PMTU is set to the IPv6 Minimum Link 1481 * According to RFC2460, PMTU is set to the IPv6 Minimum Link
1473 * MTU (1280) and a fragment header should always be included 1482 * MTU (1280) and a fragment header should always be included
1474 * after a node receiving Too Big message reporting PMTU is 1483 * after a node receiving Too Big message reporting PMTU is
1475 * less than the IPv6 Minimum Link MTU. 1484 * less than the IPv6 Minimum Link MTU.
@@ -1581,7 +1590,7 @@ static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixle
1581 if (!fn) 1590 if (!fn)
1582 goto out; 1591 goto out;
1583 1592
1584 for (rt = fn->leaf; rt; rt = rt->u.next) { 1593 for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
1585 if (rt->rt6i_dev->ifindex != ifindex) 1594 if (rt->rt6i_dev->ifindex != ifindex)
1586 continue; 1595 continue;
1587 if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY)) 1596 if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY))
@@ -1623,7 +1632,7 @@ static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixle
1623#endif 1632#endif
1624 1633
1625struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *dev) 1634struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *dev)
1626{ 1635{
1627 struct rt6_info *rt; 1636 struct rt6_info *rt;
1628 struct fib6_table *table; 1637 struct fib6_table *table;
1629 1638
@@ -1632,7 +1641,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d
1632 return NULL; 1641 return NULL;
1633 1642
1634 write_lock_bh(&table->tb6_lock); 1643 write_lock_bh(&table->tb6_lock);
1635 for (rt = table->tb6_root.leaf; rt; rt=rt->u.next) { 1644 for (rt = table->tb6_root.leaf; rt; rt=rt->u.dst.rt6_next) {
1636 if (dev == rt->rt6i_dev && 1645 if (dev == rt->rt6i_dev &&
1637 ((rt->rt6i_flags & (RTF_ADDRCONF | RTF_DEFAULT)) == (RTF_ADDRCONF | RTF_DEFAULT)) && 1646 ((rt->rt6i_flags & (RTF_ADDRCONF | RTF_DEFAULT)) == (RTF_ADDRCONF | RTF_DEFAULT)) &&
1638 ipv6_addr_equal(&rt->rt6i_gateway, addr)) 1647 ipv6_addr_equal(&rt->rt6i_gateway, addr))
@@ -1675,7 +1684,7 @@ void rt6_purge_dflt_routers(void)
1675 1684
1676restart: 1685restart:
1677 read_lock_bh(&table->tb6_lock); 1686 read_lock_bh(&table->tb6_lock);
1678 for (rt = table->tb6_root.leaf; rt; rt = rt->u.next) { 1687 for (rt = table->tb6_root.leaf; rt; rt = rt->u.dst.rt6_next) {
1679 if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) { 1688 if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
1680 dst_hold(&rt->u.dst); 1689 dst_hold(&rt->u.dst);
1681 read_unlock_bh(&table->tb6_lock); 1690 read_unlock_bh(&table->tb6_lock);
@@ -1887,8 +1896,8 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
1887 */ 1896 */
1888 if (rt->rt6i_dev == arg->dev && 1897 if (rt->rt6i_dev == arg->dev &&
1889 !dst_metric_locked(&rt->u.dst, RTAX_MTU) && 1898 !dst_metric_locked(&rt->u.dst, RTAX_MTU) &&
1890 (dst_mtu(&rt->u.dst) > arg->mtu || 1899 (dst_mtu(&rt->u.dst) > arg->mtu ||
1891 (dst_mtu(&rt->u.dst) < arg->mtu && 1900 (dst_mtu(&rt->u.dst) < arg->mtu &&
1892 dst_mtu(&rt->u.dst) == idev->cnf.mtu6))) 1901 dst_mtu(&rt->u.dst) == idev->cnf.mtu6)))
1893 rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu; 1902 rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu;
1894 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu); 1903 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu);
@@ -2040,7 +2049,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
2040 2049
2041 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags); 2050 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags);
2042 if (nlh == NULL) 2051 if (nlh == NULL)
2043 return -ENOBUFS; 2052 return -EMSGSIZE;
2044 2053
2045 rtm = nlmsg_data(nlh); 2054 rtm = nlmsg_data(nlh);
2046 rtm->rtm_family = AF_INET6; 2055 rtm->rtm_family = AF_INET6;
@@ -2074,13 +2083,13 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
2074 2083
2075 if (dst) { 2084 if (dst) {
2076 NLA_PUT(skb, RTA_DST, 16, dst); 2085 NLA_PUT(skb, RTA_DST, 16, dst);
2077 rtm->rtm_dst_len = 128; 2086 rtm->rtm_dst_len = 128;
2078 } else if (rtm->rtm_dst_len) 2087 } else if (rtm->rtm_dst_len)
2079 NLA_PUT(skb, RTA_DST, 16, &rt->rt6i_dst.addr); 2088 NLA_PUT(skb, RTA_DST, 16, &rt->rt6i_dst.addr);
2080#ifdef CONFIG_IPV6_SUBTREES 2089#ifdef CONFIG_IPV6_SUBTREES
2081 if (src) { 2090 if (src) {
2082 NLA_PUT(skb, RTA_SRC, 16, src); 2091 NLA_PUT(skb, RTA_SRC, 16, src);
2083 rtm->rtm_src_len = 128; 2092 rtm->rtm_src_len = 128;
2084 } else if (rtm->rtm_src_len) 2093 } else if (rtm->rtm_src_len)
2085 NLA_PUT(skb, RTA_SRC, 16, &rt->rt6i_src.addr); 2094 NLA_PUT(skb, RTA_SRC, 16, &rt->rt6i_src.addr);
2086#endif 2095#endif
@@ -2111,7 +2120,8 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
2111 return nlmsg_end(skb, nlh); 2120 return nlmsg_end(skb, nlh);
2112 2121
2113nla_put_failure: 2122nla_put_failure:
2114 return nlmsg_cancel(skb, nlh); 2123 nlmsg_cancel(skb, nlh);
2124 return -EMSGSIZE;
2115} 2125}
2116 2126
2117int rt6_dump_route(struct rt6_info *rt, void *p_arg) 2127int rt6_dump_route(struct rt6_info *rt, void *p_arg)
@@ -2222,9 +2232,12 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info)
2222 goto errout; 2232 goto errout;
2223 2233
2224 err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0); 2234 err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0);
2225 /* failure implies BUG in rt6_nlmsg_size() */ 2235 if (err < 0) {
2226 BUG_ON(err < 0); 2236 /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
2227 2237 WARN_ON(err == -EMSGSIZE);
2238 kfree_skb(skb);
2239 goto errout;
2240 }
2228 err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); 2241 err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any());
2229errout: 2242errout:
2230 if (err < 0) 2243 if (err < 0)
@@ -2286,7 +2299,7 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2286 arg->len += sprintf(arg->buffer + arg->len, 2299 arg->len += sprintf(arg->buffer + arg->len,
2287 " %08x %08x %08x %08x %8s\n", 2300 " %08x %08x %08x %08x %8s\n",
2288 rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt), 2301 rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
2289 rt->u.dst.__use, rt->rt6i_flags, 2302 rt->u.dst.__use, rt->rt6i_flags,
2290 rt->rt6i_dev ? rt->rt6i_dev->name : ""); 2303 rt->rt6i_dev ? rt->rt6i_dev->name : "");
2291 return 0; 2304 return 0;
2292} 2305}
@@ -2332,7 +2345,7 @@ static int rt6_stats_seq_open(struct inode *inode, struct file *file)
2332 return single_open(file, rt6_stats_seq_show, NULL); 2345 return single_open(file, rt6_stats_seq_show, NULL);
2333} 2346}
2334 2347
2335static struct file_operations rt6_stats_seq_fops = { 2348static const struct file_operations rt6_stats_seq_fops = {
2336 .owner = THIS_MODULE, 2349 .owner = THIS_MODULE,
2337 .open = rt6_stats_seq_open, 2350 .open = rt6_stats_seq_open,
2338 .read = seq_read, 2351 .read = seq_read,
@@ -2358,91 +2371,91 @@ int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, struct file * filp,
2358} 2371}
2359 2372
2360ctl_table ipv6_route_table[] = { 2373ctl_table ipv6_route_table[] = {
2361 { 2374 {
2362 .ctl_name = NET_IPV6_ROUTE_FLUSH, 2375 .ctl_name = NET_IPV6_ROUTE_FLUSH,
2363 .procname = "flush", 2376 .procname = "flush",
2364 .data = &flush_delay, 2377 .data = &flush_delay,
2365 .maxlen = sizeof(int), 2378 .maxlen = sizeof(int),
2366 .mode = 0200, 2379 .mode = 0200,
2367 .proc_handler = &ipv6_sysctl_rtcache_flush 2380 .proc_handler = &ipv6_sysctl_rtcache_flush
2368 }, 2381 },
2369 { 2382 {
2370 .ctl_name = NET_IPV6_ROUTE_GC_THRESH, 2383 .ctl_name = NET_IPV6_ROUTE_GC_THRESH,
2371 .procname = "gc_thresh", 2384 .procname = "gc_thresh",
2372 .data = &ip6_dst_ops.gc_thresh, 2385 .data = &ip6_dst_ops.gc_thresh,
2373 .maxlen = sizeof(int), 2386 .maxlen = sizeof(int),
2374 .mode = 0644, 2387 .mode = 0644,
2375 .proc_handler = &proc_dointvec, 2388 .proc_handler = &proc_dointvec,
2376 }, 2389 },
2377 { 2390 {
2378 .ctl_name = NET_IPV6_ROUTE_MAX_SIZE, 2391 .ctl_name = NET_IPV6_ROUTE_MAX_SIZE,
2379 .procname = "max_size", 2392 .procname = "max_size",
2380 .data = &ip6_rt_max_size, 2393 .data = &ip6_rt_max_size,
2381 .maxlen = sizeof(int), 2394 .maxlen = sizeof(int),
2382 .mode = 0644, 2395 .mode = 0644,
2383 .proc_handler = &proc_dointvec, 2396 .proc_handler = &proc_dointvec,
2384 }, 2397 },
2385 { 2398 {
2386 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL, 2399 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL,
2387 .procname = "gc_min_interval", 2400 .procname = "gc_min_interval",
2388 .data = &ip6_rt_gc_min_interval, 2401 .data = &ip6_rt_gc_min_interval,
2389 .maxlen = sizeof(int), 2402 .maxlen = sizeof(int),
2390 .mode = 0644, 2403 .mode = 0644,
2391 .proc_handler = &proc_dointvec_jiffies, 2404 .proc_handler = &proc_dointvec_jiffies,
2392 .strategy = &sysctl_jiffies, 2405 .strategy = &sysctl_jiffies,
2393 }, 2406 },
2394 { 2407 {
2395 .ctl_name = NET_IPV6_ROUTE_GC_TIMEOUT, 2408 .ctl_name = NET_IPV6_ROUTE_GC_TIMEOUT,
2396 .procname = "gc_timeout", 2409 .procname = "gc_timeout",
2397 .data = &ip6_rt_gc_timeout, 2410 .data = &ip6_rt_gc_timeout,
2398 .maxlen = sizeof(int), 2411 .maxlen = sizeof(int),
2399 .mode = 0644, 2412 .mode = 0644,
2400 .proc_handler = &proc_dointvec_jiffies, 2413 .proc_handler = &proc_dointvec_jiffies,
2401 .strategy = &sysctl_jiffies, 2414 .strategy = &sysctl_jiffies,
2402 }, 2415 },
2403 { 2416 {
2404 .ctl_name = NET_IPV6_ROUTE_GC_INTERVAL, 2417 .ctl_name = NET_IPV6_ROUTE_GC_INTERVAL,
2405 .procname = "gc_interval", 2418 .procname = "gc_interval",
2406 .data = &ip6_rt_gc_interval, 2419 .data = &ip6_rt_gc_interval,
2407 .maxlen = sizeof(int), 2420 .maxlen = sizeof(int),
2408 .mode = 0644, 2421 .mode = 0644,
2409 .proc_handler = &proc_dointvec_jiffies, 2422 .proc_handler = &proc_dointvec_jiffies,
2410 .strategy = &sysctl_jiffies, 2423 .strategy = &sysctl_jiffies,
2411 }, 2424 },
2412 { 2425 {
2413 .ctl_name = NET_IPV6_ROUTE_GC_ELASTICITY, 2426 .ctl_name = NET_IPV6_ROUTE_GC_ELASTICITY,
2414 .procname = "gc_elasticity", 2427 .procname = "gc_elasticity",
2415 .data = &ip6_rt_gc_elasticity, 2428 .data = &ip6_rt_gc_elasticity,
2416 .maxlen = sizeof(int), 2429 .maxlen = sizeof(int),
2417 .mode = 0644, 2430 .mode = 0644,
2418 .proc_handler = &proc_dointvec_jiffies, 2431 .proc_handler = &proc_dointvec_jiffies,
2419 .strategy = &sysctl_jiffies, 2432 .strategy = &sysctl_jiffies,
2420 }, 2433 },
2421 { 2434 {
2422 .ctl_name = NET_IPV6_ROUTE_MTU_EXPIRES, 2435 .ctl_name = NET_IPV6_ROUTE_MTU_EXPIRES,
2423 .procname = "mtu_expires", 2436 .procname = "mtu_expires",
2424 .data = &ip6_rt_mtu_expires, 2437 .data = &ip6_rt_mtu_expires,
2425 .maxlen = sizeof(int), 2438 .maxlen = sizeof(int),
2426 .mode = 0644, 2439 .mode = 0644,
2427 .proc_handler = &proc_dointvec_jiffies, 2440 .proc_handler = &proc_dointvec_jiffies,
2428 .strategy = &sysctl_jiffies, 2441 .strategy = &sysctl_jiffies,
2429 }, 2442 },
2430 { 2443 {
2431 .ctl_name = NET_IPV6_ROUTE_MIN_ADVMSS, 2444 .ctl_name = NET_IPV6_ROUTE_MIN_ADVMSS,
2432 .procname = "min_adv_mss", 2445 .procname = "min_adv_mss",
2433 .data = &ip6_rt_min_advmss, 2446 .data = &ip6_rt_min_advmss,
2434 .maxlen = sizeof(int), 2447 .maxlen = sizeof(int),
2435 .mode = 0644, 2448 .mode = 0644,
2436 .proc_handler = &proc_dointvec_jiffies, 2449 .proc_handler = &proc_dointvec_jiffies,
2437 .strategy = &sysctl_jiffies, 2450 .strategy = &sysctl_jiffies,
2438 }, 2451 },
2439 { 2452 {
2440 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS, 2453 .ctl_name = NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS,
2441 .procname = "gc_min_interval_ms", 2454 .procname = "gc_min_interval_ms",
2442 .data = &ip6_rt_gc_min_interval, 2455 .data = &ip6_rt_gc_min_interval,
2443 .maxlen = sizeof(int), 2456 .maxlen = sizeof(int),
2444 .mode = 0644, 2457 .mode = 0644,
2445 .proc_handler = &proc_dointvec_ms_jiffies, 2458 .proc_handler = &proc_dointvec_ms_jiffies,
2446 .strategy = &sysctl_ms_jiffies, 2459 .strategy = &sysctl_ms_jiffies,
2447 }, 2460 },
2448 { .ctl_name = 0 } 2461 { .ctl_name = 0 }
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 77b7b0911438..4d3cf301e1fc 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -3,7 +3,7 @@
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
8 * 8 *
9 * $Id: sit.c,v 1.53 2001/09/25 05:09:53 davem Exp $ 9 * $Id: sit.c,v 1.53 2001/09/25 05:09:53 davem Exp $
@@ -410,7 +410,7 @@ static inline __be32 try_6to4(struct in6_addr *v6dst)
410 __be32 dst = 0; 410 __be32 dst = 0;
411 411
412 if (v6dst->s6_addr16[0] == htons(0x2002)) { 412 if (v6dst->s6_addr16[0] == htons(0x2002)) {
413 /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */ 413 /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */
414 memcpy(&dst, &v6dst->s6_addr16[1], 4); 414 memcpy(&dst, &v6dst->s6_addr16[1], 4);
415 } 415 }
416 return dst; 416 return dst;
@@ -434,7 +434,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
434 int max_headroom; /* The extra header space needed */ 434 int max_headroom; /* The extra header space needed */
435 __be32 dst = tiph->daddr; 435 __be32 dst = tiph->daddr;
436 int mtu; 436 int mtu;
437 struct in6_addr *addr6; 437 struct in6_addr *addr6;
438 int addr_type; 438 int addr_type;
439 439
440 if (tunnel->recursion++) { 440 if (tunnel->recursion++) {
@@ -537,7 +537,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
537 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); 537 struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
538 if (!new_skb) { 538 if (!new_skb) {
539 ip_rt_put(rt); 539 ip_rt_put(rt);
540 stats->tx_dropped++; 540 stats->tx_dropped++;
541 dev_kfree_skb(skb); 541 dev_kfree_skb(skb);
542 tunnel->recursion--; 542 tunnel->recursion--;
543 return 0; 543 return 0;
@@ -686,7 +686,8 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
686 goto done; 686 goto done;
687 dev = t->dev; 687 dev = t->dev;
688 } 688 }
689 err = unregister_netdevice(dev); 689 unregister_netdevice(dev);
690 err = 0;
690 break; 691 break;
691 692
692 default: 693 default:
@@ -830,7 +831,7 @@ static int __init sit_init(void)
830 return -EAGAIN; 831 return -EAGAIN;
831 } 832 }
832 833
833 ipip6_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0", 834 ipip6_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0",
834 ipip6_tunnel_setup); 835 ipip6_tunnel_setup);
835 if (!ipip6_fb_tunnel_dev) { 836 if (!ipip6_fb_tunnel_dev) {
836 err = -ENOMEM; 837 err = -ENOMEM;
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 7a4639db1346..25e8e7783fee 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -92,7 +92,7 @@ static ctl_table ipv6_net_table[] = {
92 .mode = 0555, 92 .mode = 0555,
93 .child = ipv6_table 93 .child = ipv6_table
94 }, 94 },
95 { .ctl_name = 0 } 95 { .ctl_name = 0 }
96}; 96};
97 97
98static ctl_table ipv6_root_table[] = { 98static ctl_table ipv6_root_table[] = {
@@ -102,7 +102,7 @@ static ctl_table ipv6_root_table[] = {
102 .mode = 0555, 102 .mode = 0555,
103 .child = ipv6_net_table 103 .child = ipv6_net_table
104 }, 104 },
105 { .ctl_name = 0 } 105 { .ctl_name = 0 }
106}; 106};
107 107
108void ipv6_sysctl_register(void) 108void ipv6_sysctl_register(void)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index c25e930c2c69..f57a9baa6b27 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1,13 +1,13 @@
1/* 1/*
2 * TCP over IPv6 2 * TCP over IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * $Id: tcp_ipv6.c,v 1.144 2002/02/01 22:01:04 davem Exp $ 8 * $Id: tcp_ipv6.c,v 1.144 2002/02/01 22:01:04 davem Exp $
9 * 9 *
10 * Based on: 10 * Based on:
11 * linux/net/ipv4/tcp.c 11 * linux/net/ipv4/tcp.c
12 * linux/net/ipv4/tcp_input.c 12 * linux/net/ipv4/tcp_input.c
13 * linux/net/ipv4/tcp_output.c 13 * linux/net/ipv4/tcp_output.c
@@ -74,7 +74,7 @@ static struct socket *tcp6_socket;
74 74
75static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb); 75static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
76static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); 76static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
77static void tcp_v6_send_check(struct sock *sk, int len, 77static void tcp_v6_send_check(struct sock *sk, int len,
78 struct sk_buff *skb); 78 struct sk_buff *skb);
79 79
80static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); 80static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);
@@ -106,8 +106,8 @@ static void tcp_v6_hash(struct sock *sk)
106} 106}
107 107
108static __inline__ __sum16 tcp_v6_check(struct tcphdr *th, int len, 108static __inline__ __sum16 tcp_v6_check(struct tcphdr *th, int len,
109 struct in6_addr *saddr, 109 struct in6_addr *saddr,
110 struct in6_addr *daddr, 110 struct in6_addr *daddr,
111 __wsum base) 111 __wsum base)
112{ 112{
113 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base); 113 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base);
@@ -121,11 +121,11 @@ static __u32 tcp_v6_init_sequence(struct sk_buff *skb)
121 skb->h.th->source); 121 skb->h.th->source);
122} 122}
123 123
124static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 124static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
125 int addr_len) 125 int addr_len)
126{ 126{
127 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; 127 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
128 struct inet_sock *inet = inet_sk(sk); 128 struct inet_sock *inet = inet_sk(sk);
129 struct inet_connection_sock *icsk = inet_csk(sk); 129 struct inet_connection_sock *icsk = inet_csk(sk);
130 struct ipv6_pinfo *np = inet6_sk(sk); 130 struct ipv6_pinfo *np = inet6_sk(sk);
131 struct tcp_sock *tp = tcp_sk(sk); 131 struct tcp_sock *tp = tcp_sk(sk);
@@ -135,10 +135,10 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
135 int addr_type; 135 int addr_type;
136 int err; 136 int err;
137 137
138 if (addr_len < SIN6_LEN_RFC2133) 138 if (addr_len < SIN6_LEN_RFC2133)
139 return -EINVAL; 139 return -EINVAL;
140 140
141 if (usin->sin6_family != AF_INET6) 141 if (usin->sin6_family != AF_INET6)
142 return(-EAFNOSUPPORT); 142 return(-EAFNOSUPPORT);
143 143
144 memset(&fl, 0, sizeof(fl)); 144 memset(&fl, 0, sizeof(fl));
@@ -157,11 +157,11 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
157 } 157 }
158 158
159 /* 159 /*
160 * connect() to INADDR_ANY means loopback (BSD'ism). 160 * connect() to INADDR_ANY means loopback (BSD'ism).
161 */ 161 */
162 162
163 if(ipv6_addr_any(&usin->sin6_addr)) 163 if(ipv6_addr_any(&usin->sin6_addr))
164 usin->sin6_addr.s6_addr[15] = 0x1; 164 usin->sin6_addr.s6_addr[15] = 0x1;
165 165
166 addr_type = ipv6_addr_type(&usin->sin6_addr); 166 addr_type = ipv6_addr_type(&usin->sin6_addr);
167 167
@@ -265,7 +265,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
265 if (final_p) 265 if (final_p)
266 ipv6_addr_copy(&fl.fl6_dst, final_p); 266 ipv6_addr_copy(&fl.fl6_dst, final_p);
267 267
268 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) 268 if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
269 goto failure; 269 goto failure;
270 270
271 if (saddr == NULL) { 271 if (saddr == NULL) {
@@ -323,7 +323,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
323 struct ipv6_pinfo *np; 323 struct ipv6_pinfo *np;
324 struct sock *sk; 324 struct sock *sk;
325 int err; 325 int err;
326 struct tcp_sock *tp; 326 struct tcp_sock *tp;
327 __u32 seq; 327 __u32 seq;
328 328
329 sk = inet6_lookup(&tcp_hashinfo, &hdr->daddr, th->dest, &hdr->saddr, 329 sk = inet6_lookup(&tcp_hashinfo, &hdr->daddr, th->dest, &hdr->saddr,
@@ -347,7 +347,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
347 goto out; 347 goto out;
348 348
349 tp = tcp_sk(sk); 349 tp = tcp_sk(sk);
350 seq = ntohl(th->seq); 350 seq = ntohl(th->seq);
351 if (sk->sk_state != TCP_LISTEN && 351 if (sk->sk_state != TCP_LISTEN &&
352 !between(seq, tp->snd_una, tp->snd_nxt)) { 352 !between(seq, tp->snd_una, tp->snd_nxt)) {
353 NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); 353 NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
@@ -434,7 +434,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
434 434
435 case TCP_SYN_SENT: 435 case TCP_SYN_SENT:
436 case TCP_SYN_RECV: /* Cannot happen. 436 case TCP_SYN_RECV: /* Cannot happen.
437 It can, it SYNs are crossed. --ANK */ 437 It can, it SYNs are crossed. --ANK */
438 if (!sock_owned_by_user(sk)) { 438 if (!sock_owned_by_user(sk)) {
439 sk->sk_err = err; 439 sk->sk_err = err;
440 sk->sk_error_report(sk); /* Wake people up to see the error (see connect in sock.c) */ 440 sk->sk_error_report(sk); /* Wake people up to see the error (see connect in sock.c) */
@@ -519,7 +519,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
519 } 519 }
520 520
521done: 521done:
522 if (opt && opt != np->opt) 522 if (opt && opt != np->opt)
523 sock_kfree_s(sk, opt, opt->tot_len); 523 sock_kfree_s(sk, opt, opt->tot_len);
524 dst_release(dst); 524 dst_release(dst);
525 return err; 525 return err;
@@ -950,8 +950,8 @@ static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
950 th->check = ~csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0); 950 th->check = ~csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0);
951 skb->csum_offset = offsetof(struct tcphdr, check); 951 skb->csum_offset = offsetof(struct tcphdr, check);
952 } else { 952 } else {
953 th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 953 th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP,
954 csum_partial((char *)th, th->doff<<2, 954 csum_partial((char *)th, th->doff<<2,
955 skb->csum)); 955 skb->csum));
956 } 956 }
957} 957}
@@ -977,7 +977,7 @@ static int tcp_v6_gso_send_check(struct sk_buff *skb)
977 977
978static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb) 978static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
979{ 979{
980 struct tcphdr *th = skb->h.th, *t1; 980 struct tcphdr *th = skb->h.th, *t1;
981 struct sk_buff *buff; 981 struct sk_buff *buff;
982 struct flowi fl; 982 struct flowi fl;
983 int tot_len = sizeof(*th); 983 int tot_len = sizeof(*th);
@@ -989,7 +989,7 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
989 return; 989 return;
990 990
991 if (!ipv6_unicast_destination(skb)) 991 if (!ipv6_unicast_destination(skb))
992 return; 992 return;
993 993
994#ifdef CONFIG_TCP_MD5SIG 994#ifdef CONFIG_TCP_MD5SIG
995 if (sk) 995 if (sk)
@@ -1008,8 +1008,8 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1008 1008
1009 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len, 1009 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,
1010 GFP_ATOMIC); 1010 GFP_ATOMIC);
1011 if (buff == NULL) 1011 if (buff == NULL)
1012 return; 1012 return;
1013 1013
1014 skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len); 1014 skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len);
1015 1015
@@ -1021,9 +1021,9 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1021 t1->source = th->dest; 1021 t1->source = th->dest;
1022 t1->doff = tot_len / 4; 1022 t1->doff = tot_len / 4;
1023 t1->rst = 1; 1023 t1->rst = 1;
1024 1024
1025 if(th->ack) { 1025 if(th->ack) {
1026 t1->seq = th->ack_seq; 1026 t1->seq = th->ack_seq;
1027 } else { 1027 } else {
1028 t1->ack = 1; 1028 t1->ack = 1;
1029 t1->ack_seq = htonl(ntohl(th->seq) + th->syn + th->fin 1029 t1->ack_seq = htonl(ntohl(th->seq) + th->syn + th->fin
@@ -1128,7 +1128,7 @@ static void tcp_v6_send_ack(struct tcp_timewait_sock *tw,
1128 t1->window = htons(win); 1128 t1->window = htons(win);
1129 1129
1130 topt = (__be32 *)(t1 + 1); 1130 topt = (__be32 *)(t1 + 1);
1131 1131
1132 if (ts) { 1132 if (ts) {
1133 *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 1133 *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
1134 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); 1134 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
@@ -1243,15 +1243,15 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1243 return tcp_v4_conn_request(sk, skb); 1243 return tcp_v4_conn_request(sk, skb);
1244 1244
1245 if (!ipv6_unicast_destination(skb)) 1245 if (!ipv6_unicast_destination(skb))
1246 goto drop; 1246 goto drop;
1247 1247
1248 /* 1248 /*
1249 * There are no SYN attacks on IPv6, yet... 1249 * There are no SYN attacks on IPv6, yet...
1250 */ 1250 */
1251 if (inet_csk_reqsk_queue_is_full(sk) && !isn) { 1251 if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
1252 if (net_ratelimit()) 1252 if (net_ratelimit())
1253 printk(KERN_INFO "TCPv6: dropping request, synflood is possible\n"); 1253 printk(KERN_INFO "TCPv6: dropping request, synflood is possible\n");
1254 goto drop; 1254 goto drop;
1255 } 1255 }
1256 1256
1257 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) 1257 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
@@ -1292,7 +1292,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
1292 ipv6_addr_type(&treq->rmt_addr) & IPV6_ADDR_LINKLOCAL) 1292 ipv6_addr_type(&treq->rmt_addr) & IPV6_ADDR_LINKLOCAL)
1293 treq->iif = inet6_iif(skb); 1293 treq->iif = inet6_iif(skb);
1294 1294
1295 if (isn == 0) 1295 if (isn == 0)
1296 isn = tcp_v6_init_sequence(skb); 1296 isn = tcp_v6_init_sequence(skb);
1297 1297
1298 tcp_rsk(req)->snt_isn = isn; 1298 tcp_rsk(req)->snt_isn = isn;
@@ -1334,7 +1334,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1334 1334
1335 newsk = tcp_v4_syn_recv_sock(sk, skb, req, dst); 1335 newsk = tcp_v4_syn_recv_sock(sk, skb, req, dst);
1336 1336
1337 if (newsk == NULL) 1337 if (newsk == NULL)
1338 return NULL; 1338 return NULL;
1339 1339
1340 newtcp6sk = (struct tcp6_sock *)newsk; 1340 newtcp6sk = (struct tcp6_sock *)newsk;
@@ -1419,7 +1419,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1419 1419
1420 if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0) 1420 if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0)
1421 goto out; 1421 goto out;
1422 } 1422 }
1423 1423
1424 newsk = tcp_create_openreq_child(sk, req, skb); 1424 newsk = tcp_create_openreq_child(sk, req, skb);
1425 if (newsk == NULL) 1425 if (newsk == NULL)
@@ -1448,7 +1448,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1448 ipv6_addr_copy(&newnp->rcv_saddr, &treq->loc_addr); 1448 ipv6_addr_copy(&newnp->rcv_saddr, &treq->loc_addr);
1449 newsk->sk_bound_dev_if = treq->iif; 1449 newsk->sk_bound_dev_if = treq->iif;
1450 1450
1451 /* Now IPv6 options... 1451 /* Now IPv6 options...
1452 1452
1453 First: no IPv4 options. 1453 First: no IPv4 options.
1454 */ 1454 */
@@ -1592,7 +1592,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1592 looks not very well thought. For now we latch 1592 looks not very well thought. For now we latch
1593 options, received in the last packet, enqueued 1593 options, received in the last packet, enqueued
1594 by tcp. Feel free to propose better solution. 1594 by tcp. Feel free to propose better solution.
1595 --ANK (980728) 1595 --ANK (980728)
1596 */ 1596 */
1597 if (np->rxopt.all) 1597 if (np->rxopt.all)
1598 opt_skb = skb_clone(skb, GFP_ATOMIC); 1598 opt_skb = skb_clone(skb, GFP_ATOMIC);
@@ -1610,7 +1610,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1610 if (skb->len < (skb->h.th->doff<<2) || tcp_checksum_complete(skb)) 1610 if (skb->len < (skb->h.th->doff<<2) || tcp_checksum_complete(skb))
1611 goto csum_err; 1611 goto csum_err;
1612 1612
1613 if (sk->sk_state == TCP_LISTEN) { 1613 if (sk->sk_state == TCP_LISTEN) {
1614 struct sock *nsk = tcp_v6_hnd_req(sk, skb); 1614 struct sock *nsk = tcp_v6_hnd_req(sk, skb);
1615 if (!nsk) 1615 if (!nsk)
1616 goto discard; 1616 goto discard;
@@ -1620,7 +1620,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1620 * otherwise we just shortcircuit this and continue with 1620 * otherwise we just shortcircuit this and continue with
1621 * the new socket.. 1621 * the new socket..
1622 */ 1622 */
1623 if(nsk != sk) { 1623 if(nsk != sk) {
1624 if (tcp_child_process(sk, nsk, skb)) 1624 if (tcp_child_process(sk, nsk, skb))
1625 goto reset; 1625 goto reset;
1626 if (opt_skb) 1626 if (opt_skb)
@@ -1681,7 +1681,7 @@ ipv6_pktoptions:
1681static int tcp_v6_rcv(struct sk_buff **pskb) 1681static int tcp_v6_rcv(struct sk_buff **pskb)
1682{ 1682{
1683 struct sk_buff *skb = *pskb; 1683 struct sk_buff *skb = *pskb;
1684 struct tcphdr *th; 1684 struct tcphdr *th;
1685 struct sock *sk; 1685 struct sock *sk;
1686 int ret; 1686 int ret;
1687 1687
@@ -1739,10 +1739,10 @@ process:
1739 ret = 0; 1739 ret = 0;
1740 if (!sock_owned_by_user(sk)) { 1740 if (!sock_owned_by_user(sk)) {
1741#ifdef CONFIG_NET_DMA 1741#ifdef CONFIG_NET_DMA
1742 struct tcp_sock *tp = tcp_sk(sk); 1742 struct tcp_sock *tp = tcp_sk(sk);
1743 if (tp->ucopy.dma_chan) 1743 if (tp->ucopy.dma_chan)
1744 ret = tcp_v6_do_rcv(sk, skb); 1744 ret = tcp_v6_do_rcv(sk, skb);
1745 else 1745 else
1746#endif 1746#endif
1747 { 1747 {
1748 if (!tcp_prequeue(sk, skb)) 1748 if (!tcp_prequeue(sk, skb))
@@ -1945,7 +1945,7 @@ static int tcp_v6_destroy_sock(struct sock *sk)
1945} 1945}
1946 1946
1947/* Proc filesystem TCPv6 sock list dumping. */ 1947/* Proc filesystem TCPv6 sock list dumping. */
1948static void get_openreq6(struct seq_file *seq, 1948static void get_openreq6(struct seq_file *seq,
1949 struct sock *sk, struct request_sock *req, int i, int uid) 1949 struct sock *sk, struct request_sock *req, int i, int uid)
1950{ 1950{
1951 int ttd = req->expires - jiffies; 1951 int ttd = req->expires - jiffies;
@@ -1967,11 +1967,11 @@ static void get_openreq6(struct seq_file *seq,
1967 ntohs(inet_rsk(req)->rmt_port), 1967 ntohs(inet_rsk(req)->rmt_port),
1968 TCP_SYN_RECV, 1968 TCP_SYN_RECV,
1969 0,0, /* could print option size, but that is af dependent. */ 1969 0,0, /* could print option size, but that is af dependent. */
1970 1, /* timers active (only the expire timer) */ 1970 1, /* timers active (only the expire timer) */
1971 jiffies_to_clock_t(ttd), 1971 jiffies_to_clock_t(ttd),
1972 req->retrans, 1972 req->retrans,
1973 uid, 1973 uid,
1974 0, /* non standard timer */ 1974 0, /* non standard timer */
1975 0, /* open_requests have no inode */ 1975 0, /* open_requests have no inode */
1976 0, req); 1976 0, req);
1977} 1977}
@@ -2014,7 +2014,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
2014 src->s6_addr32[2], src->s6_addr32[3], srcp, 2014 src->s6_addr32[2], src->s6_addr32[3], srcp,
2015 dest->s6_addr32[0], dest->s6_addr32[1], 2015 dest->s6_addr32[0], dest->s6_addr32[1],
2016 dest->s6_addr32[2], dest->s6_addr32[3], destp, 2016 dest->s6_addr32[2], dest->s6_addr32[3], destp,
2017 sp->sk_state, 2017 sp->sk_state,
2018 tp->write_seq-tp->snd_una, 2018 tp->write_seq-tp->snd_una,
2019 (sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq), 2019 (sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
2020 timer_active, 2020 timer_active,
@@ -2031,7 +2031,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
2031 ); 2031 );
2032} 2032}
2033 2033
2034static void get_timewait6_sock(struct seq_file *seq, 2034static void get_timewait6_sock(struct seq_file *seq,
2035 struct inet_timewait_sock *tw, int i) 2035 struct inet_timewait_sock *tw, int i)
2036{ 2036{
2037 struct in6_addr *dest, *src; 2037 struct in6_addr *dest, *src;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index f52a5c3cc0a3..ccf2f4d196be 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * UDP over IPv6 2 * UDP over IPv6
3 * Linux INET6 implementation 3 * Linux INET6 implementation
4 * 4 *
5 * Authors: 5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt> 6 * Pedro Roque <roque@di.fc.ul.pt>
7 * 7 *
8 * Based on linux/ipv4/udp.c 8 * Based on linux/ipv4/udp.c
9 * 9 *
@@ -67,11 +67,11 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
67 unsigned short hnum = ntohs(dport); 67 unsigned short hnum = ntohs(dport);
68 int badness = -1; 68 int badness = -1;
69 69
70 read_lock(&udp_hash_lock); 70 read_lock(&udp_hash_lock);
71 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { 71 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
72 struct inet_sock *inet = inet_sk(sk); 72 struct inet_sock *inet = inet_sk(sk);
73 73
74 if (inet->num == hnum && sk->sk_family == PF_INET6) { 74 if (sk->sk_hash == hnum && sk->sk_family == PF_INET6) {
75 struct ipv6_pinfo *np = inet6_sk(sk); 75 struct ipv6_pinfo *np = inet6_sk(sk);
76 int score = 0; 76 int score = 0;
77 if (inet->dport) { 77 if (inet->dport) {
@@ -105,7 +105,7 @@ static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
105 } 105 }
106 if (result) 106 if (result)
107 sock_hold(result); 107 sock_hold(result);
108 read_unlock(&udp_hash_lock); 108 read_unlock(&udp_hash_lock);
109 return result; 109 return result;
110} 110}
111 111
@@ -120,13 +120,13 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
120{ 120{
121 struct ipv6_pinfo *np = inet6_sk(sk); 121 struct ipv6_pinfo *np = inet6_sk(sk);
122 struct inet_sock *inet = inet_sk(sk); 122 struct inet_sock *inet = inet_sk(sk);
123 struct sk_buff *skb; 123 struct sk_buff *skb;
124 size_t copied; 124 size_t copied;
125 int err, copy_only, is_udplite = IS_UDPLITE(sk); 125 int err, copy_only, is_udplite = IS_UDPLITE(sk);
126 126
127 if (addr_len) 127 if (addr_len)
128 *addr_len=sizeof(struct sockaddr_in6); 128 *addr_len=sizeof(struct sockaddr_in6);
129 129
130 if (flags & MSG_ERRQUEUE) 130 if (flags & MSG_ERRQUEUE)
131 return ipv6_recv_error(sk, msg, len); 131 return ipv6_recv_error(sk, msg, len);
132 132
@@ -135,11 +135,11 @@ try_again:
135 if (!skb) 135 if (!skb)
136 goto out; 136 goto out;
137 137
138 copied = skb->len - sizeof(struct udphdr); 138 copied = skb->len - sizeof(struct udphdr);
139 if (copied > len) { 139 if (copied > len) {
140 copied = len; 140 copied = len;
141 msg->msg_flags |= MSG_TRUNC; 141 msg->msg_flags |= MSG_TRUNC;
142 } 142 }
143 143
144 /* 144 /*
145 * Decide whether to checksum and/or copy data. 145 * Decide whether to checksum and/or copy data.
@@ -168,7 +168,7 @@ try_again:
168 /* Copy the address. */ 168 /* Copy the address. */
169 if (msg->msg_name) { 169 if (msg->msg_name) {
170 struct sockaddr_in6 *sin6; 170 struct sockaddr_in6 *sin6;
171 171
172 sin6 = (struct sockaddr_in6 *) msg->msg_name; 172 sin6 = (struct sockaddr_in6 *) msg->msg_name;
173 sin6->sin6_family = AF_INET6; 173 sin6->sin6_family = AF_INET6;
174 sin6->sin6_port = skb->h.uh->source; 174 sin6->sin6_port = skb->h.uh->source;
@@ -191,7 +191,7 @@ try_again:
191 } else { 191 } else {
192 if (np->rxopt.all) 192 if (np->rxopt.all)
193 datagram_recv_ctl(sk, msg, skb); 193 datagram_recv_ctl(sk, msg, skb);
194 } 194 }
195 195
196 err = copied; 196 err = copied;
197 if (flags & MSG_TRUNC) 197 if (flags & MSG_TRUNC)
@@ -309,7 +309,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
309 sk_for_each_from(s, node) { 309 sk_for_each_from(s, node) {
310 struct inet_sock *inet = inet_sk(s); 310 struct inet_sock *inet = inet_sk(s);
311 311
312 if (inet->num == num && s->sk_family == PF_INET6) { 312 if (s->sk_hash == num && s->sk_family == PF_INET6) {
313 struct ipv6_pinfo *np = inet6_sk(s); 313 struct ipv6_pinfo *np = inet6_sk(s);
314 if (inet->dport) { 314 if (inet->dport) {
315 if (inet->dport != rmt_port) 315 if (inet->dport != rmt_port)
@@ -339,7 +339,7 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
339 * so we don't need to lock the hashes. 339 * so we don't need to lock the hashes.
340 */ 340 */
341static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr, 341static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr,
342 struct in6_addr *daddr, struct hlist_head udptable[]) 342 struct in6_addr *daddr, struct hlist_head udptable[])
343{ 343{
344 struct sock *sk, *sk2; 344 struct sock *sk, *sk2;
345 const struct udphdr *uh = skb->h.uh; 345 const struct udphdr *uh = skb->h.uh;
@@ -379,7 +379,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh)
379 } 379 }
380 if (skb->ip_summed == CHECKSUM_COMPLETE && 380 if (skb->ip_summed == CHECKSUM_COMPLETE &&
381 !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr, 381 !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
382 skb->len, IPPROTO_UDP, skb->csum )) 382 skb->len, IPPROTO_UDP, skb->csum ))
383 skb->ip_summed = CHECKSUM_UNNECESSARY; 383 skb->ip_summed = CHECKSUM_UNNECESSARY;
384 384
385 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 385 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
@@ -396,7 +396,7 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
396{ 396{
397 struct sk_buff *skb = *pskb; 397 struct sk_buff *skb = *pskb;
398 struct sock *sk; 398 struct sock *sk;
399 struct udphdr *uh; 399 struct udphdr *uh;
400 struct net_device *dev = skb->dev; 400 struct net_device *dev = skb->dev;
401 struct in6_addr *saddr, *daddr; 401 struct in6_addr *saddr, *daddr;
402 u32 ulen = 0; 402 u32 ulen = 0;
@@ -437,15 +437,15 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
437 goto discard; 437 goto discard;
438 } 438 }
439 439
440 /* 440 /*
441 * Multicast receive code 441 * Multicast receive code
442 */ 442 */
443 if (ipv6_addr_is_multicast(daddr)) 443 if (ipv6_addr_is_multicast(daddr))
444 return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable); 444 return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable);
445 445
446 /* Unicast */ 446 /* Unicast */
447 447
448 /* 448 /*
449 * check socket cache ... must talk to Alan about his plans 449 * check socket cache ... must talk to Alan about his plans
450 * for sock caches... i'll skip this for now. 450 * for sock caches... i'll skip this for now.
451 */ 451 */
@@ -465,21 +465,21 @@ int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
465 kfree_skb(skb); 465 kfree_skb(skb);
466 return(0); 466 return(0);
467 } 467 }
468 468
469 /* deliver */ 469 /* deliver */
470 470
471 udpv6_queue_rcv_skb(sk, skb); 471 udpv6_queue_rcv_skb(sk, skb);
472 sock_put(sk); 472 sock_put(sk);
473 return(0); 473 return(0);
474 474
475short_packet: 475short_packet:
476 LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n", 476 LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n",
477 is_udplite? "-Lite" : "", ulen, skb->len); 477 is_udplite? "-Lite" : "", ulen, skb->len);
478 478
479discard: 479discard:
480 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite); 480 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
481 kfree_skb(skb); 481 kfree_skb(skb);
482 return(0); 482 return(0);
483} 483}
484 484
485static __inline__ int udpv6_rcv(struct sk_buff **pskb) 485static __inline__ int udpv6_rcv(struct sk_buff **pskb)
@@ -498,7 +498,7 @@ static void udp_v6_flush_pending_frames(struct sock *sk)
498 up->len = 0; 498 up->len = 0;
499 up->pending = 0; 499 up->pending = 0;
500 ip6_flush_pending_frames(sk); 500 ip6_flush_pending_frames(sk);
501 } 501 }
502} 502}
503 503
504/* 504/*
@@ -594,7 +594,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
594 if (sk->sk_state != TCP_ESTABLISHED) 594 if (sk->sk_state != TCP_ESTABLISHED)
595 return -EDESTADDRREQ; 595 return -EDESTADDRREQ;
596 daddr = &np->daddr; 596 daddr = &np->daddr;
597 } else 597 } else
598 daddr = NULL; 598 daddr = NULL;
599 599
600 if (daddr) { 600 if (daddr) {
@@ -620,7 +620,7 @@ do_udp_sendmsg:
620 */ 620 */
621 if (len > INT_MAX - sizeof(struct udphdr)) 621 if (len > INT_MAX - sizeof(struct udphdr))
622 return -EMSGSIZE; 622 return -EMSGSIZE;
623 623
624 if (up->pending) { 624 if (up->pending) {
625 /* 625 /*
626 * There are pending frames. 626 * There are pending frames.
@@ -713,7 +713,7 @@ do_udp_sendmsg:
713 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 713 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
714 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 714 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
715 fl.fl_ip_sport = inet->sport; 715 fl.fl_ip_sport = inet->sport;
716 716
717 /* merge ip6_build_xmit from ip6_output */ 717 /* merge ip6_build_xmit from ip6_output */
718 if (opt && opt->srcrt) { 718 if (opt && opt->srcrt) {
719 struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; 719 struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
@@ -736,7 +736,7 @@ do_udp_sendmsg:
736 if (final_p) 736 if (final_p)
737 ipv6_addr_copy(&fl.fl6_dst, final_p); 737 ipv6_addr_copy(&fl.fl6_dst, final_p);
738 738
739 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) 739 if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
740 goto out; 740 goto out;
741 741
742 if (hlimit < 0) { 742 if (hlimit < 0) {
@@ -911,7 +911,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
911 src->s6_addr32[2], src->s6_addr32[3], srcp, 911 src->s6_addr32[2], src->s6_addr32[3], srcp,
912 dest->s6_addr32[0], dest->s6_addr32[1], 912 dest->s6_addr32[0], dest->s6_addr32[1],
913 dest->s6_addr32[2], dest->s6_addr32[3], destp, 913 dest->s6_addr32[2], dest->s6_addr32[3], destp,
914 sp->sk_state, 914 sp->sk_state,
915 atomic_read(&sp->sk_wmem_alloc), 915 atomic_read(&sp->sk_wmem_alloc),
916 atomic_read(&sp->sk_rmem_alloc), 916 atomic_read(&sp->sk_rmem_alloc),
917 0, 0L, 0, 917 0, 0L, 0,
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index ec9878899128..6e252f318f7c 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -11,9 +11,9 @@ extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *,
11 int , int , int , __be32 , struct hlist_head []); 11 int , int , int , __be32 , struct hlist_head []);
12 12
13extern int udpv6_getsockopt(struct sock *sk, int level, int optname, 13extern int udpv6_getsockopt(struct sock *sk, int level, int optname,
14 char __user *optval, int __user *optlen); 14 char __user *optval, int __user *optlen);
15extern int udpv6_setsockopt(struct sock *sk, int level, int optname, 15extern int udpv6_setsockopt(struct sock *sk, int level, int optname,
16 char __user *optval, int optlen); 16 char __user *optval, int optlen);
17#ifdef CONFIG_COMPAT 17#ifdef CONFIG_COMPAT
18extern int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, 18extern int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
19 char __user *optval, int optlen); 19 char __user *optval, int optlen);
@@ -24,7 +24,7 @@ extern int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
24 struct msghdr *msg, size_t len); 24 struct msghdr *msg, size_t len);
25extern int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, 25extern int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
26 struct msghdr *msg, size_t len, 26 struct msghdr *msg, size_t len,
27 int noblock, int flags, int *addr_len); 27 int noblock, int flags, int *addr_len);
28extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb); 28extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb);
29extern int udpv6_destroy_sock(struct sock *sk); 29extern int udpv6_destroy_sock(struct sock *sk);
30 30
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index 5c8b7a568800..25250147bdc3 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -33,7 +33,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
33 seq = 0; 33 seq = 0;
34 if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) 34 if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0)
35 goto drop; 35 goto drop;
36 36
37 do { 37 do {
38 struct ipv6hdr *iph = skb->nh.ipv6h; 38 struct ipv6hdr *iph = skb->nh.ipv6h;
39 39
@@ -115,7 +115,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
115 __skb_push(skb, skb->data - skb->nh.raw); 115 __skb_push(skb, skb->data - skb->nh.raw);
116 116
117 NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL, 117 NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL,
118 ip6_rcv_finish); 118 ip6_rcv_finish);
119 return -1; 119 return -1;
120#else 120#else
121 return 1; 121 return 1;
@@ -142,12 +142,12 @@ int xfrm6_rcv(struct sk_buff **pskb)
142int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, 142int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
143 xfrm_address_t *saddr, u8 proto) 143 xfrm_address_t *saddr, u8 proto)
144{ 144{
145 struct xfrm_state *x = NULL; 145 struct xfrm_state *x = NULL;
146 int wildcard = 0; 146 int wildcard = 0;
147 struct in6_addr any; 147 struct in6_addr any;
148 xfrm_address_t *xany; 148 xfrm_address_t *xany;
149 struct xfrm_state *xfrm_vec_one = NULL; 149 struct xfrm_state *xfrm_vec_one = NULL;
150 int nh = 0; 150 int nh = 0;
151 int i = 0; 151 int i = 0;
152 152
153 ipv6_addr_set(&any, 0, 0, 0, 0); 153 ipv6_addr_set(&any, 0, 0, 0, 0);
@@ -168,12 +168,12 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
168 break; 168 break;
169 case 2: 169 case 2:
170 default: 170 default:
171 /* lookup state with wild-card addresses */ 171 /* lookup state with wild-card addresses */
172 wildcard = 1; /* XXX */ 172 wildcard = 1; /* XXX */
173 dst = xany; 173 dst = xany;
174 src = xany; 174 src = xany;
175 break; 175 break;
176 } 176 }
177 177
178 x = xfrm_state_lookup_byaddr(dst, src, proto, AF_INET6); 178 x = xfrm_state_lookup_byaddr(dst, src, proto, AF_INET6);
179 if (!x) 179 if (!x)
@@ -193,8 +193,8 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
193 if (unlikely(x->km.state != XFRM_STATE_VALID)) { 193 if (unlikely(x->km.state != XFRM_STATE_VALID)) {
194 spin_unlock(&x->lock); 194 spin_unlock(&x->lock);
195 xfrm_state_put(x); 195 xfrm_state_put(x);
196 x = NULL; 196 x = NULL;
197 continue; 197 continue;
198 } 198 }
199 if (xfrm_state_check_expire(x)) { 199 if (xfrm_state_check_expire(x)) {
200 spin_unlock(&x->lock); 200 spin_unlock(&x->lock);
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 5e7d8a7d6414..0bc866c0d83c 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -25,6 +25,12 @@ static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
25 IP6_ECN_set_ce(inner_iph); 25 IP6_ECN_set_ce(inner_iph);
26} 26}
27 27
28static inline void ip6ip_ecn_decapsulate(struct sk_buff *skb)
29{
30 if (INET_ECN_is_ce(ipv6_get_dsfield(skb->nh.ipv6h)))
31 IP_ECN_set_ce(skb->h.ipiph);
32}
33
28/* Add encapsulation header. 34/* Add encapsulation header.
29 * 35 *
30 * The top IP header will be constructed per RFC 2401. The following fields 36 * The top IP header will be constructed per RFC 2401. The following fields
@@ -40,6 +46,7 @@ static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
40static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) 46static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
41{ 47{
42 struct dst_entry *dst = skb->dst; 48 struct dst_entry *dst = skb->dst;
49 struct xfrm_dst *xdst = (struct xfrm_dst*)dst;
43 struct ipv6hdr *iph, *top_iph; 50 struct ipv6hdr *iph, *top_iph;
44 int dsfield; 51 int dsfield;
45 52
@@ -52,16 +59,24 @@ static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
52 skb->h.ipv6h = top_iph + 1; 59 skb->h.ipv6h = top_iph + 1;
53 60
54 top_iph->version = 6; 61 top_iph->version = 6;
55 top_iph->priority = iph->priority; 62 if (xdst->route->ops->family == AF_INET6) {
56 top_iph->flow_lbl[0] = iph->flow_lbl[0]; 63 top_iph->priority = iph->priority;
57 top_iph->flow_lbl[1] = iph->flow_lbl[1]; 64 top_iph->flow_lbl[0] = iph->flow_lbl[0];
58 top_iph->flow_lbl[2] = iph->flow_lbl[2]; 65 top_iph->flow_lbl[1] = iph->flow_lbl[1];
66 top_iph->flow_lbl[2] = iph->flow_lbl[2];
67 top_iph->nexthdr = IPPROTO_IPV6;
68 } else {
69 top_iph->priority = 0;
70 top_iph->flow_lbl[0] = 0;
71 top_iph->flow_lbl[1] = 0;
72 top_iph->flow_lbl[2] = 0;
73 top_iph->nexthdr = IPPROTO_IPIP;
74 }
59 dsfield = ipv6_get_dsfield(top_iph); 75 dsfield = ipv6_get_dsfield(top_iph);
60 dsfield = INET_ECN_encapsulate(dsfield, dsfield); 76 dsfield = INET_ECN_encapsulate(dsfield, dsfield);
61 if (x->props.flags & XFRM_STATE_NOECN) 77 if (x->props.flags & XFRM_STATE_NOECN)
62 dsfield &= ~INET_ECN_MASK; 78 dsfield &= ~INET_ECN_MASK;
63 ipv6_change_dsfield(top_iph, 0, dsfield); 79 ipv6_change_dsfield(top_iph, 0, dsfield);
64 top_iph->nexthdr = IPPROTO_IPV6;
65 top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT); 80 top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT);
66 ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr); 81 ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
67 ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); 82 ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
@@ -72,7 +87,8 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
72{ 87{
73 int err = -EINVAL; 88 int err = -EINVAL;
74 89
75 if (skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPV6) 90 if (skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPV6
91 && skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPIP)
76 goto out; 92 goto out;
77 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) 93 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
78 goto out; 94 goto out;
@@ -81,10 +97,16 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
81 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) 97 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
82 goto out; 98 goto out;
83 99
84 if (x->props.flags & XFRM_STATE_DECAP_DSCP) 100 if (skb->nh.raw[IP6CB(skb)->nhoff] == IPPROTO_IPV6) {
85 ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h); 101 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
86 if (!(x->props.flags & XFRM_STATE_NOECN)) 102 ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h);
87 ipip6_ecn_decapsulate(skb); 103 if (!(x->props.flags & XFRM_STATE_NOECN))
104 ipip6_ecn_decapsulate(skb);
105 } else {
106 if (!(x->props.flags & XFRM_STATE_NOECN))
107 ip6ip_ecn_decapsulate(skb);
108 skb->protocol = htons(ETH_P_IP);
109 }
88 skb->mac.raw = memmove(skb->data - skb->mac_len, 110 skb->mac.raw = memmove(skb->data - skb->mac_len,
89 skb->mac.raw, skb->mac_len); 111 skb->mac.raw, skb->mac_len);
90 skb->nh.raw = skb->data; 112 skb->nh.raw = skb->data;
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index c260ea104c52..d6d786b89d2b 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -2,7 +2,7 @@
2 * xfrm6_output.c - Common IPsec encapsulation code for IPv6. 2 * xfrm6_output.c - Common IPsec encapsulation code for IPv6.
3 * Copyright (C) 2002 USAGI/WIDE Project 3 * Copyright (C) 2002 USAGI/WIDE Project
4 * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au> 4 * Copyright (c) 2004 Herbert Xu <herbert@gondor.apana.org.au>
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
@@ -46,7 +46,7 @@ static int xfrm6_output_one(struct sk_buff *skb)
46 struct dst_entry *dst = skb->dst; 46 struct dst_entry *dst = skb->dst;
47 struct xfrm_state *x = dst->xfrm; 47 struct xfrm_state *x = dst->xfrm;
48 int err; 48 int err;
49 49
50 if (skb->ip_summed == CHECKSUM_PARTIAL) { 50 if (skb->ip_summed == CHECKSUM_PARTIAL) {
51 err = skb_checksum_help(skb); 51 err = skb_checksum_help(skb);
52 if (err) 52 if (err)
@@ -81,7 +81,7 @@ static int xfrm6_output_one(struct sk_buff *skb)
81 spin_unlock_bh(&x->lock); 81 spin_unlock_bh(&x->lock);
82 82
83 skb->nh.raw = skb->data; 83 skb->nh.raw = skb->data;
84 84
85 if (!(skb->dst = dst_pop(dst))) { 85 if (!(skb->dst = dst_pop(dst))) {
86 err = -EHOSTUNREACH; 86 err = -EHOSTUNREACH;
87 goto error_nolock; 87 goto error_nolock;
@@ -108,7 +108,7 @@ static int xfrm6_output_finish2(struct sk_buff *skb)
108 108
109 while (likely((err = xfrm6_output_one(skb)) == 0)) { 109 while (likely((err = xfrm6_output_one(skb)) == 0)) {
110 nf_reset(skb); 110 nf_reset(skb);
111 111
112 err = nf_hook(PF_INET6, NF_IP6_LOCAL_OUT, &skb, NULL, 112 err = nf_hook(PF_INET6, NF_IP6_LOCAL_OUT, &skb, NULL,
113 skb->dst->dev, dst_output); 113 skb->dst->dev, dst_output);
114 if (unlikely(err != 1)) 114 if (unlikely(err != 1))
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 8dffd4daae9c..b1133f27c8ae 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -8,7 +8,7 @@
8 * IPv6 support 8 * IPv6 support
9 * YOSHIFUJI Hideaki 9 * YOSHIFUJI Hideaki
10 * Split up af-specific portion 10 * Split up af-specific portion
11 * 11 *
12 */ 12 */
13 13
14#include <linux/compiler.h> 14#include <linux/compiler.h>
@@ -131,13 +131,11 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
131 struct dst_entry *dst, *dst_prev; 131 struct dst_entry *dst, *dst_prev;
132 struct rt6_info *rt0 = (struct rt6_info*)(*dst_p); 132 struct rt6_info *rt0 = (struct rt6_info*)(*dst_p);
133 struct rt6_info *rt = rt0; 133 struct rt6_info *rt = rt0;
134 struct in6_addr *remote = &fl->fl6_dst;
135 struct in6_addr *local = &fl->fl6_src;
136 struct flowi fl_tunnel = { 134 struct flowi fl_tunnel = {
137 .nl_u = { 135 .nl_u = {
138 .ip6_u = { 136 .ip6_u = {
139 .saddr = *local, 137 .saddr = fl->fl6_src,
140 .daddr = *remote 138 .daddr = fl->fl6_dst,
141 } 139 }
142 } 140 }
143 }; 141 };
@@ -153,7 +151,6 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
153 for (i = 0; i < nx; i++) { 151 for (i = 0; i < nx; i++) {
154 struct dst_entry *dst1 = dst_alloc(&xfrm6_dst_ops); 152 struct dst_entry *dst1 = dst_alloc(&xfrm6_dst_ops);
155 struct xfrm_dst *xdst; 153 struct xfrm_dst *xdst;
156 int tunnel = 0;
157 154
158 if (unlikely(dst1 == NULL)) { 155 if (unlikely(dst1 == NULL)) {
159 err = -ENOBUFS; 156 err = -ENOBUFS;
@@ -177,19 +174,29 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
177 174
178 dst1->next = dst_prev; 175 dst1->next = dst_prev;
179 dst_prev = dst1; 176 dst_prev = dst1;
180 if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { 177
181 remote = __xfrm6_bundle_addr_remote(xfrm[i], remote);
182 local = __xfrm6_bundle_addr_local(xfrm[i], local);
183 tunnel = 1;
184 }
185 __xfrm6_bundle_len_inc(&header_len, &nfheader_len, xfrm[i]); 178 __xfrm6_bundle_len_inc(&header_len, &nfheader_len, xfrm[i]);
186 trailer_len += xfrm[i]->props.trailer_len; 179 trailer_len += xfrm[i]->props.trailer_len;
187 180
188 if (tunnel) { 181 if (xfrm[i]->props.mode == XFRM_MODE_TUNNEL ||
189 ipv6_addr_copy(&fl_tunnel.fl6_dst, remote); 182 xfrm[i]->props.mode == XFRM_MODE_ROUTEOPTIMIZATION) {
190 ipv6_addr_copy(&fl_tunnel.fl6_src, local); 183 unsigned short encap_family = xfrm[i]->props.family;
184 switch(encap_family) {
185 case AF_INET:
186 fl_tunnel.fl4_dst = xfrm[i]->id.daddr.a4;
187 fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4;
188 break;
189 case AF_INET6:
190 ipv6_addr_copy(&fl_tunnel.fl6_dst, __xfrm6_bundle_addr_remote(xfrm[i], &fl->fl6_dst));
191
192 ipv6_addr_copy(&fl_tunnel.fl6_src, __xfrm6_bundle_addr_remote(xfrm[i], &fl->fl6_src));
193 break;
194 default:
195 BUG_ON(1);
196 }
197
191 err = xfrm_dst_lookup((struct xfrm_dst **) &rt, 198 err = xfrm_dst_lookup((struct xfrm_dst **) &rt,
192 &fl_tunnel, AF_INET6); 199 &fl_tunnel, encap_family);
193 if (err) 200 if (err)
194 goto error; 201 goto error;
195 } else 202 } else
@@ -208,6 +215,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
208 i = 0; 215 i = 0;
209 for (; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) { 216 for (; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) {
210 struct xfrm_dst *x = (struct xfrm_dst*)dst_prev; 217 struct xfrm_dst *x = (struct xfrm_dst*)dst_prev;
218 struct xfrm_state_afinfo *afinfo;
211 219
212 dst_prev->xfrm = xfrm[i++]; 220 dst_prev->xfrm = xfrm[i++];
213 dst_prev->dev = rt->u.dst.dev; 221 dst_prev->dev = rt->u.dst.dev;
@@ -224,16 +232,26 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
224 /* Copy neighbour for reachability confirmation */ 232 /* Copy neighbour for reachability confirmation */
225 dst_prev->neighbour = neigh_clone(rt->u.dst.neighbour); 233 dst_prev->neighbour = neigh_clone(rt->u.dst.neighbour);
226 dst_prev->input = rt->u.dst.input; 234 dst_prev->input = rt->u.dst.input;
227 dst_prev->output = xfrm6_output; 235 /* XXX: When IPv4 is implemented as module and can be unloaded,
236 * we should manage reference to xfrm4_output in afinfo->output.
237 * Miyazawa
238 */
239 afinfo = xfrm_state_get_afinfo(dst_prev->xfrm->props.family);
240 if (!afinfo) {
241 dst = *dst_p;
242 goto error;
243 };
244 dst_prev->output = afinfo->output;
245 xfrm_state_put_afinfo(afinfo);
228 /* Sheit... I remember I did this right. Apparently, 246 /* Sheit... I remember I did this right. Apparently,
229 * it was magically lost, so this code needs audit */ 247 * it was magically lost, so this code needs audit */
230 x->u.rt6.rt6i_flags = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL); 248 x->u.rt6.rt6i_flags = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL);
231 x->u.rt6.rt6i_metric = rt0->rt6i_metric; 249 x->u.rt6.rt6i_metric = rt0->rt6i_metric;
232 x->u.rt6.rt6i_node = rt0->rt6i_node; 250 x->u.rt6.rt6i_node = rt0->rt6i_node;
233 x->u.rt6.rt6i_gateway = rt0->rt6i_gateway; 251 x->u.rt6.rt6i_gateway = rt0->rt6i_gateway;
234 memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway)); 252 memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway));
235 x->u.rt6.rt6i_dst = rt0->rt6i_dst; 253 x->u.rt6.rt6i_dst = rt0->rt6i_dst;
236 x->u.rt6.rt6i_src = rt0->rt6i_src; 254 x->u.rt6.rt6i_src = rt0->rt6i_src;
237 x->u.rt6.rt6i_idev = rt0->rt6i_idev; 255 x->u.rt6.rt6i_idev = rt0->rt6i_idev;
238 in6_dev_hold(rt0->rt6i_idev); 256 in6_dev_hold(rt0->rt6i_idev);
239 __xfrm6_bundle_len_dec(&header_len, &nfheader_len, x->u.dst.xfrm); 257 __xfrm6_bundle_len_dec(&header_len, &nfheader_len, x->u.dst.xfrm);
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
index 9ddaa9d41539..baa461b9f74e 100644
--- a/net/ipv6/xfrm6_state.c
+++ b/net/ipv6/xfrm6_state.c
@@ -8,7 +8,7 @@
8 * IPv6 support 8 * IPv6 support
9 * YOSHIFUJI Hideaki @USAGI 9 * YOSHIFUJI Hideaki @USAGI
10 * Split up af-specific portion 10 * Split up af-specific portion
11 * 11 *
12 */ 12 */
13 13
14#include <net/xfrm.h> 14#include <net/xfrm.h>
@@ -171,6 +171,7 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = {
171 .init_tempsel = __xfrm6_init_tempsel, 171 .init_tempsel = __xfrm6_init_tempsel,
172 .tmpl_sort = __xfrm6_tmpl_sort, 172 .tmpl_sort = __xfrm6_tmpl_sort,
173 .state_sort = __xfrm6_state_sort, 173 .state_sort = __xfrm6_state_sort,
174 .output = xfrm6_output,
174}; 175};
175 176
176void __init xfrm6_state_init(void) 177void __init xfrm6_state_init(void)
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 12e426b9aacd..fb0228772f01 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -5,12 +5,12 @@
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -32,7 +32,7 @@
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33 33
34/* 34/*
35 * xfrm_tunnel_spi things are for allocating unique id ("spi") 35 * xfrm_tunnel_spi things are for allocating unique id ("spi")
36 * per xfrm_address_t. 36 * per xfrm_address_t.
37 */ 37 */
38struct xfrm6_tunnel_spi { 38struct xfrm6_tunnel_spi {
@@ -155,8 +155,8 @@ static u32 __xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
155 155
156 for (spi = xfrm6_tunnel_spi; spi <= XFRM6_TUNNEL_SPI_MAX; spi++) { 156 for (spi = xfrm6_tunnel_spi; spi <= XFRM6_TUNNEL_SPI_MAX; spi++) {
157 index = xfrm6_tunnel_spi_hash_byspi(spi); 157 index = xfrm6_tunnel_spi_hash_byspi(spi);
158 hlist_for_each_entry(x6spi, pos, 158 hlist_for_each_entry(x6spi, pos,
159 &xfrm6_tunnel_spi_byspi[index], 159 &xfrm6_tunnel_spi_byspi[index],
160 list_byspi) { 160 list_byspi) {
161 if (x6spi->spi == spi) 161 if (x6spi->spi == spi)
162 goto try_next_1; 162 goto try_next_1;
@@ -167,8 +167,8 @@ try_next_1:;
167 } 167 }
168 for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tunnel_spi; spi++) { 168 for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tunnel_spi; spi++) {
169 index = xfrm6_tunnel_spi_hash_byspi(spi); 169 index = xfrm6_tunnel_spi_hash_byspi(spi);
170 hlist_for_each_entry(x6spi, pos, 170 hlist_for_each_entry(x6spi, pos,
171 &xfrm6_tunnel_spi_byspi[index], 171 &xfrm6_tunnel_spi_byspi[index],
172 list_byspi) { 172 list_byspi) {
173 if (x6spi->spi == spi) 173 if (x6spi->spi == spi)
174 goto try_next_2; 174 goto try_next_2;
@@ -222,7 +222,7 @@ void xfrm6_tunnel_free_spi(xfrm_address_t *saddr)
222 222
223 write_lock_bh(&xfrm6_tunnel_spi_lock); 223 write_lock_bh(&xfrm6_tunnel_spi_lock);
224 224
225 hlist_for_each_entry_safe(x6spi, pos, n, 225 hlist_for_each_entry_safe(x6spi, pos, n,
226 &xfrm6_tunnel_spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)], 226 &xfrm6_tunnel_spi_byaddr[xfrm6_tunnel_spi_hash_byaddr(saddr)],
227 list_byaddr) 227 list_byaddr)
228 { 228 {
@@ -269,9 +269,9 @@ static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
269{ 269{
270 /* xfrm6_tunnel native err handling */ 270 /* xfrm6_tunnel native err handling */
271 switch (type) { 271 switch (type) {
272 case ICMPV6_DEST_UNREACH: 272 case ICMPV6_DEST_UNREACH:
273 switch (code) { 273 switch (code) {
274 case ICMPV6_NOROUTE: 274 case ICMPV6_NOROUTE:
275 case ICMPV6_ADM_PROHIBITED: 275 case ICMPV6_ADM_PROHIBITED:
276 case ICMPV6_NOT_NEIGHBOUR: 276 case ICMPV6_NOT_NEIGHBOUR:
277 case ICMPV6_ADDR_UNREACH: 277 case ICMPV6_ADDR_UNREACH:
@@ -287,7 +287,7 @@ static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
287 case ICMPV6_EXC_HOPLIMIT: 287 case ICMPV6_EXC_HOPLIMIT:
288 break; 288 break;
289 case ICMPV6_EXC_FRAGTIME: 289 case ICMPV6_EXC_FRAGTIME:
290 default: 290 default:
291 break; 291 break;
292 } 292 }
293 break; 293 break;