aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-02-14 01:02:32 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-02-14 01:02:32 -0500
commitac98695d6c1508b724f246f38ce57fb4e3cec356 (patch)
tree189969a3689b9b83eaf39314a7942cc781ff836b /net
parentd9bc125caf592b7d081021f32ce5b717efdf70c8 (diff)
parent93bbad8fe13a25dcf7f3bc628a71d1a7642ae61b (diff)
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_if.c8
-rw-r--r--net/bridge/br_notify.c4
-rw-r--r--net/ipv4/ipip.c6
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c4
-rw-r--r--net/ipv4/tcp_output.c4
-rw-r--r--net/ipv4/tunnel4.c50
-rw-r--r--net/ipv4/xfrm4_input.c4
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c1
-rw-r--r--net/ipv4/xfrm4_tunnel.c29
-rw-r--r--net/ipv6/Kconfig1
-rw-r--r--net/ipv6/inet6_hashtables.c2
-rw-r--r--net/ipv6/ip6_tunnel.c6
-rw-r--r--net/ipv6/sit.c30
-rw-r--r--net/ipv6/tunnel6.c43
-rw-r--r--net/ipv6/xfrm6_input.c3
-rw-r--r--net/ipv6/xfrm6_tunnel.c19
-rw-r--r--net/sched/sch_hfsc.c15
-rw-r--r--net/xfrm/xfrm_policy.c2
18 files changed, 175 insertions, 56 deletions
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index f35c1a378d0..aff6a779c9c 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -108,6 +108,7 @@ static void port_carrier_check(struct work_struct *work)
108 spin_unlock_bh(&br->lock); 108 spin_unlock_bh(&br->lock);
109 } 109 }
110done: 110done:
111 dev_put(dev);
111 rtnl_unlock(); 112 rtnl_unlock();
112} 113}
113 114
@@ -161,7 +162,8 @@ static void del_nbp(struct net_bridge_port *p)
161 162
162 dev_set_promiscuity(dev, -1); 163 dev_set_promiscuity(dev, -1);
163 164
164 cancel_delayed_work(&p->carrier_check); 165 if (cancel_delayed_work(&p->carrier_check))
166 dev_put(dev);
165 167
166 spin_lock_bh(&br->lock); 168 spin_lock_bh(&br->lock);
167 br_stp_disable_port(p); 169 br_stp_disable_port(p);
@@ -444,7 +446,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
444 spin_lock_bh(&br->lock); 446 spin_lock_bh(&br->lock);
445 br_stp_recalculate_bridge_id(br); 447 br_stp_recalculate_bridge_id(br);
446 br_features_recompute(br); 448 br_features_recompute(br);
447 schedule_delayed_work(&p->carrier_check, BR_PORT_DEBOUNCE); 449 if (schedule_delayed_work(&p->carrier_check, BR_PORT_DEBOUNCE))
450 dev_hold(dev);
451
448 spin_unlock_bh(&br->lock); 452 spin_unlock_bh(&br->lock);
449 453
450 dev_set_mtu(br->dev, br_min_mtu(br)); 454 dev_set_mtu(br->dev, br_min_mtu(br));
diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c
index 8cd3e422907..3311c4e3082 100644
--- a/net/bridge/br_notify.c
+++ b/net/bridge/br_notify.c
@@ -56,7 +56,9 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
56 56
57 case NETDEV_CHANGE: 57 case NETDEV_CHANGE:
58 if (br->dev->flags & IFF_UP) 58 if (br->dev->flags & IFF_UP)
59 schedule_delayed_work(&p->carrier_check, BR_PORT_DEBOUNCE); 59 if (schedule_delayed_work(&p->carrier_check,
60 BR_PORT_DEBOUNCE))
61 dev_hold(dev);
60 break; 62 break;
61 63
62 case NETDEV_FEAT_CHANGE: 64 case NETDEV_FEAT_CHANGE:
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 475bcd1e418..9b561e633b0 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -871,7 +871,7 @@ static int __init ipip_init(void)
871 871
872 printk(banner); 872 printk(banner);
873 873
874 if (xfrm4_tunnel_register(&ipip_handler)) { 874 if (xfrm4_tunnel_register(&ipip_handler, AF_INET)) {
875 printk(KERN_INFO "ipip init: can't register tunnel\n"); 875 printk(KERN_INFO "ipip init: can't register tunnel\n");
876 return -EAGAIN; 876 return -EAGAIN;
877 } 877 }
@@ -893,7 +893,7 @@ static int __init ipip_init(void)
893 err2: 893 err2:
894 free_netdev(ipip_fb_tunnel_dev); 894 free_netdev(ipip_fb_tunnel_dev);
895 err1: 895 err1:
896 xfrm4_tunnel_deregister(&ipip_handler); 896 xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
897 goto out; 897 goto out;
898} 898}
899 899
@@ -913,7 +913,7 @@ static void __exit ipip_destroy_tunnels(void)
913 913
914static void __exit ipip_fini(void) 914static void __exit ipip_fini(void)
915{ 915{
916 if (xfrm4_tunnel_deregister(&ipip_handler)) 916 if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET))
917 printk(KERN_INFO "ipip close: can't deregister tunnel\n"); 917 printk(KERN_INFO "ipip close: can't deregister tunnel\n");
918 918
919 rtnl_lock(); 919 rtnl_lock();
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index a9eb3635fff..80f739e2182 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -80,6 +80,10 @@ static void send_reset(struct sk_buff *oldskb, int hook)
80 nskb->mark = 0; 80 nskb->mark = 0;
81 skb_init_secmark(nskb); 81 skb_init_secmark(nskb);
82 82
83 skb_shinfo(nskb)->gso_size = 0;
84 skb_shinfo(nskb)->gso_segs = 0;
85 skb_shinfo(nskb)->gso_type = 0;
86
83 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl); 87 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
84 88
85 /* Swap source and dest */ 89 /* Swap source and dest */
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index cebe9aa918a..dc151139b5a 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -481,7 +481,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
481 /* RFC1323: The window in SYN & SYN/ACK segments 481 /* RFC1323: The window in SYN & SYN/ACK segments
482 * is never scaled. 482 * is never scaled.
483 */ 483 */
484 th->window = htons(tp->rcv_wnd); 484 th->window = htons(min(tp->rcv_wnd, 65535U));
485 } else { 485 } else {
486 th->window = htons(tcp_select_window(sk)); 486 th->window = htons(tcp_select_window(sk));
487 } 487 }
@@ -2160,7 +2160,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2160 } 2160 }
2161 2161
2162 /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */ 2162 /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */
2163 th->window = htons(req->rcv_wnd); 2163 th->window = htons(min(req->rcv_wnd, 65535U));
2164 2164
2165 TCP_SKB_CB(skb)->when = tcp_time_stamp; 2165 TCP_SKB_CB(skb)->when = tcp_time_stamp;
2166 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, 2166 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok,
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index 8d30c48f090..a794a8ca8b4 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -14,9 +14,10 @@
14#include <net/xfrm.h> 14#include <net/xfrm.h>
15 15
16static struct xfrm_tunnel *tunnel4_handlers; 16static struct xfrm_tunnel *tunnel4_handlers;
17static struct xfrm_tunnel *tunnel64_handlers;
17static DEFINE_MUTEX(tunnel4_mutex); 18static DEFINE_MUTEX(tunnel4_mutex);
18 19
19int xfrm4_tunnel_register(struct xfrm_tunnel *handler) 20int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family)
20{ 21{
21 struct xfrm_tunnel **pprev; 22 struct xfrm_tunnel **pprev;
22 int ret = -EEXIST; 23 int ret = -EEXIST;
@@ -24,7 +25,8 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler)
24 25
25 mutex_lock(&tunnel4_mutex); 26 mutex_lock(&tunnel4_mutex);
26 27
27 for (pprev = &tunnel4_handlers; *pprev; pprev = &(*pprev)->next) { 28 for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers;
29 *pprev; pprev = &(*pprev)->next) {
28 if ((*pprev)->priority > priority) 30 if ((*pprev)->priority > priority)
29 break; 31 break;
30 if ((*pprev)->priority == priority) 32 if ((*pprev)->priority == priority)
@@ -44,14 +46,15 @@ err:
44 46
45EXPORT_SYMBOL(xfrm4_tunnel_register); 47EXPORT_SYMBOL(xfrm4_tunnel_register);
46 48
47int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler) 49int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family)
48{ 50{
49 struct xfrm_tunnel **pprev; 51 struct xfrm_tunnel **pprev;
50 int ret = -ENOENT; 52 int ret = -ENOENT;
51 53
52 mutex_lock(&tunnel4_mutex); 54 mutex_lock(&tunnel4_mutex);
53 55
54 for (pprev = &tunnel4_handlers; *pprev; pprev = &(*pprev)->next) { 56 for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers;
57 *pprev; pprev = &(*pprev)->next) {
55 if (*pprev == handler) { 58 if (*pprev == handler) {
56 *pprev = handler->next; 59 *pprev = handler->next;
57 ret = 0; 60 ret = 0;
@@ -86,6 +89,26 @@ drop:
86 return 0; 89 return 0;
87} 90}
88 91
92#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
93static int tunnel64_rcv(struct sk_buff *skb)
94{
95 struct xfrm_tunnel *handler;
96
97 if (!pskb_may_pull(skb, sizeof(struct iphdr)))
98 goto drop;
99
100 for (handler = tunnel64_handlers; handler; handler = handler->next)
101 if (!handler->handler(skb))
102 return 0;
103
104 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
105
106drop:
107 kfree_skb(skb);
108 return 0;
109}
110#endif
111
89static void tunnel4_err(struct sk_buff *skb, u32 info) 112static void tunnel4_err(struct sk_buff *skb, u32 info)
90{ 113{
91 struct xfrm_tunnel *handler; 114 struct xfrm_tunnel *handler;
@@ -101,17 +124,36 @@ static struct net_protocol tunnel4_protocol = {
101 .no_policy = 1, 124 .no_policy = 1,
102}; 125};
103 126
127#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
128static struct net_protocol tunnel64_protocol = {
129 .handler = tunnel64_rcv,
130 .err_handler = tunnel4_err,
131 .no_policy = 1,
132};
133#endif
134
104static int __init tunnel4_init(void) 135static int __init tunnel4_init(void)
105{ 136{
106 if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) { 137 if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
107 printk(KERN_ERR "tunnel4 init: can't add protocol\n"); 138 printk(KERN_ERR "tunnel4 init: can't add protocol\n");
108 return -EAGAIN; 139 return -EAGAIN;
109 } 140 }
141#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
142 if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
143 printk(KERN_ERR "tunnel64 init: can't add protocol\n");
144 inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
145 return -EAGAIN;
146 }
147#endif
110 return 0; 148 return 0;
111} 149}
112 150
113static void __exit tunnel4_fini(void) 151static void __exit tunnel4_fini(void)
114{ 152{
153#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
154 if (inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6))
155 printk(KERN_ERR "tunnel64 close: can't remove protocol\n");
156#endif
115 if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP)) 157 if (inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP))
116 printk(KERN_ERR "tunnel4 close: can't remove protocol\n"); 158 printk(KERN_ERR "tunnel4 close: can't remove protocol\n");
117} 159}
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
index 289146bdb8b..78e80deb7e8 100644
--- a/net/ipv4/xfrm4_input.c
+++ b/net/ipv4/xfrm4_input.c
@@ -27,6 +27,7 @@ static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32
27{ 27{
28 switch (nexthdr) { 28 switch (nexthdr) {
29 case IPPROTO_IPIP: 29 case IPPROTO_IPIP:
30 case IPPROTO_IPV6:
30 *spi = skb->nh.iph->saddr; 31 *spi = skb->nh.iph->saddr;
31 *seq = 0; 32 *seq = 0;
32 return 0; 33 return 0;
@@ -70,7 +71,8 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
70 if (xfrm_nr == XFRM_MAX_DEPTH) 71 if (xfrm_nr == XFRM_MAX_DEPTH)
71 goto drop; 72 goto drop;
72 73
73 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi, iph->protocol, AF_INET); 74 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi,
75 iph->protocol != IPPROTO_IPV6 ? iph->protocol : IPPROTO_IPIP, AF_INET);
74 if (x == NULL) 76 if (x == NULL)
75 goto drop; 77 goto drop;
76 78
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index e54c5494c88..e1cab33fdad 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -95,6 +95,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
95 95
96 switch(iph->protocol){ 96 switch(iph->protocol){
97 case IPPROTO_IPIP: 97 case IPPROTO_IPIP:
98 break;
98#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 99#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
99 case IPPROTO_IPV6: 100 case IPPROTO_IPV6:
100 break; 101 break;
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index 1be6762b2d4..3eef06454da 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -64,24 +64,45 @@ static struct xfrm_tunnel xfrm_tunnel_handler = {
64 .priority = 2, 64 .priority = 2,
65}; 65};
66 66
67#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
68static struct xfrm_tunnel xfrm64_tunnel_handler = {
69 .handler = xfrm4_rcv,
70 .err_handler = xfrm_tunnel_err,
71 .priority = 2,
72};
73#endif
74
67static int __init ipip_init(void) 75static int __init ipip_init(void)
68{ 76{
69 if (xfrm_register_type(&ipip_type, AF_INET) < 0) { 77 if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
70 printk(KERN_INFO "ipip init: can't add xfrm type\n"); 78 printk(KERN_INFO "ipip init: can't add xfrm type\n");
71 return -EAGAIN; 79 return -EAGAIN;
72 } 80 }
73 if (xfrm4_tunnel_register(&xfrm_tunnel_handler)) { 81
74 printk(KERN_INFO "ipip init: can't add xfrm handler\n"); 82 if (xfrm4_tunnel_register(&xfrm_tunnel_handler, AF_INET)) {
83 printk(KERN_INFO "ipip init: can't add xfrm handler for AF_INET\n");
84 xfrm_unregister_type(&ipip_type, AF_INET);
85 return -EAGAIN;
86 }
87#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
88 if (xfrm4_tunnel_register(&xfrm64_tunnel_handler, AF_INET6)) {
89 printk(KERN_INFO "ipip init: can't add xfrm handler for AF_INET6\n");
90 xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET);
75 xfrm_unregister_type(&ipip_type, AF_INET); 91 xfrm_unregister_type(&ipip_type, AF_INET);
76 return -EAGAIN; 92 return -EAGAIN;
77 } 93 }
94#endif
78 return 0; 95 return 0;
79} 96}
80 97
81static void __exit ipip_fini(void) 98static void __exit ipip_fini(void)
82{ 99{
83 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler)) 100#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
84 printk(KERN_INFO "ipip close: can't remove xfrm handler\n"); 101 if (xfrm4_tunnel_deregister(&xfrm64_tunnel_handler, AF_INET6))
102 printk(KERN_INFO "ipip close: can't remove xfrm handler for AF_INET6\n");
103#endif
104 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET))
105 printk(KERN_INFO "ipip close: can't remove xfrm handler for AF_INET\n");
85 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0) 106 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0)
86 printk(KERN_INFO "ipip close: can't remove xfrm type\n"); 107 printk(KERN_INFO "ipip close: can't remove xfrm type\n");
87} 108}
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index deb4101a2a8..79682efb14b 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -156,6 +156,7 @@ config INET6_XFRM_MODE_ROUTEOPTIMIZATION
156config IPV6_SIT 156config IPV6_SIT
157 tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)" 157 tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)"
158 depends on IPV6 158 depends on IPV6
159 select INET_TUNNEL
159 default y 160 default y
160 ---help--- 161 ---help---
161 Tunneling means encapsulating data of one protocol type within 162 Tunneling means encapsulating data of one protocol type within
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 30b16da739c..ae6b0e7eb48 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -172,7 +172,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
172 const struct in6_addr *saddr = &np->daddr; 172 const struct in6_addr *saddr = &np->daddr;
173 const int dif = sk->sk_bound_dev_if; 173 const int dif = sk->sk_bound_dev_if;
174 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport); 174 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
175 const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, 175 const unsigned int hash = inet6_ehashfn(daddr, lport, saddr,
176 inet->dport); 176 inet->dport);
177 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 177 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
178 struct sock *sk2; 178 struct sock *sk2;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 367b7483298..662edb82689 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1128,7 +1128,7 @@ static int __init ip6_tunnel_init(void)
1128{ 1128{
1129 int err; 1129 int err;
1130 1130
1131 if (xfrm6_tunnel_register(&ip6ip6_handler)) { 1131 if (xfrm6_tunnel_register(&ip6ip6_handler, AF_INET6)) {
1132 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n"); 1132 printk(KERN_ERR "ip6ip6 init: can't register tunnel\n");
1133 return -EAGAIN; 1133 return -EAGAIN;
1134 } 1134 }
@@ -1147,7 +1147,7 @@ static int __init ip6_tunnel_init(void)
1147 } 1147 }
1148 return 0; 1148 return 0;
1149fail: 1149fail:
1150 xfrm6_tunnel_deregister(&ip6ip6_handler); 1150 xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6);
1151 return err; 1151 return err;
1152} 1152}
1153 1153
@@ -1171,7 +1171,7 @@ static void __exit ip6ip6_destroy_tunnels(void)
1171 1171
1172static void __exit ip6_tunnel_cleanup(void) 1172static void __exit ip6_tunnel_cleanup(void)
1173{ 1173{
1174 if (xfrm6_tunnel_deregister(&ip6ip6_handler)) 1174 if (xfrm6_tunnel_deregister(&ip6ip6_handler, AF_INET6))
1175 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n"); 1175 printk(KERN_INFO "ip6ip6 close: can't deregister tunnel\n");
1176 1176
1177 rtnl_lock(); 1177 rtnl_lock();
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 4d3cf301e1f..862ed7c52c3 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -216,7 +216,7 @@ static void ipip6_tunnel_uninit(struct net_device *dev)
216} 216}
217 217
218 218
219static void ipip6_err(struct sk_buff *skb, u32 info) 219static int ipip6_err(struct sk_buff *skb, u32 info)
220{ 220{
221#ifndef I_WISH_WORLD_WERE_PERFECT 221#ifndef I_WISH_WORLD_WERE_PERFECT
222 222
@@ -228,21 +228,22 @@ static void ipip6_err(struct sk_buff *skb, u32 info)
228 int type = skb->h.icmph->type; 228 int type = skb->h.icmph->type;
229 int code = skb->h.icmph->code; 229 int code = skb->h.icmph->code;
230 struct ip_tunnel *t; 230 struct ip_tunnel *t;
231 int err;
231 232
232 switch (type) { 233 switch (type) {
233 default: 234 default:
234 case ICMP_PARAMETERPROB: 235 case ICMP_PARAMETERPROB:
235 return; 236 return 0;
236 237
237 case ICMP_DEST_UNREACH: 238 case ICMP_DEST_UNREACH:
238 switch (code) { 239 switch (code) {
239 case ICMP_SR_FAILED: 240 case ICMP_SR_FAILED:
240 case ICMP_PORT_UNREACH: 241 case ICMP_PORT_UNREACH:
241 /* Impossible event. */ 242 /* Impossible event. */
242 return; 243 return 0;
243 case ICMP_FRAG_NEEDED: 244 case ICMP_FRAG_NEEDED:
244 /* Soft state for pmtu is maintained by IP core. */ 245 /* Soft state for pmtu is maintained by IP core. */
245 return; 246 return 0;
246 default: 247 default:
247 /* All others are translated to HOST_UNREACH. 248 /* All others are translated to HOST_UNREACH.
248 rfc2003 contains "deep thoughts" about NET_UNREACH, 249 rfc2003 contains "deep thoughts" about NET_UNREACH,
@@ -253,14 +254,18 @@ static void ipip6_err(struct sk_buff *skb, u32 info)
253 break; 254 break;
254 case ICMP_TIME_EXCEEDED: 255 case ICMP_TIME_EXCEEDED:
255 if (code != ICMP_EXC_TTL) 256 if (code != ICMP_EXC_TTL)
256 return; 257 return 0;
257 break; 258 break;
258 } 259 }
259 260
261 err = -ENOENT;
262
260 read_lock(&ipip6_lock); 263 read_lock(&ipip6_lock);
261 t = ipip6_tunnel_lookup(iph->daddr, iph->saddr); 264 t = ipip6_tunnel_lookup(iph->daddr, iph->saddr);
262 if (t == NULL || t->parms.iph.daddr == 0) 265 if (t == NULL || t->parms.iph.daddr == 0)
263 goto out; 266 goto out;
267
268 err = 0;
264 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) 269 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
265 goto out; 270 goto out;
266 271
@@ -271,7 +276,7 @@ static void ipip6_err(struct sk_buff *skb, u32 info)
271 t->err_time = jiffies; 276 t->err_time = jiffies;
272out: 277out:
273 read_unlock(&ipip6_lock); 278 read_unlock(&ipip6_lock);
274 return; 279 return err;
275#else 280#else
276 struct iphdr *iph = (struct iphdr*)dp; 281 struct iphdr *iph = (struct iphdr*)dp;
277 int hlen = iph->ihl<<2; 282 int hlen = iph->ihl<<2;
@@ -332,7 +337,7 @@ out:
332 /* Prepare fake skb to feed it to icmpv6_send */ 337 /* Prepare fake skb to feed it to icmpv6_send */
333 skb2 = skb_clone(skb, GFP_ATOMIC); 338 skb2 = skb_clone(skb, GFP_ATOMIC);
334 if (skb2 == NULL) 339 if (skb2 == NULL)
335 return; 340 return 0;
336 dst_release(skb2->dst); 341 dst_release(skb2->dst);
337 skb2->dst = NULL; 342 skb2->dst = NULL;
338 skb_pull(skb2, skb->data - (u8*)iph6); 343 skb_pull(skb2, skb->data - (u8*)iph6);
@@ -355,7 +360,7 @@ out:
355 } 360 }
356 } 361 }
357 kfree_skb(skb2); 362 kfree_skb(skb2);
358 return; 363 return 0;
359#endif 364#endif
360} 365}
361 366
@@ -791,9 +796,10 @@ static int __init ipip6_fb_tunnel_init(struct net_device *dev)
791 return 0; 796 return 0;
792} 797}
793 798
794static struct net_protocol sit_protocol = { 799static struct xfrm_tunnel sit_handler = {
795 .handler = ipip6_rcv, 800 .handler = ipip6_rcv,
796 .err_handler = ipip6_err, 801 .err_handler = ipip6_err,
802 .priority = 1,
797}; 803};
798 804
799static void __exit sit_destroy_tunnels(void) 805static void __exit sit_destroy_tunnels(void)
@@ -812,7 +818,7 @@ static void __exit sit_destroy_tunnels(void)
812 818
813static void __exit sit_cleanup(void) 819static void __exit sit_cleanup(void)
814{ 820{
815 inet_del_protocol(&sit_protocol, IPPROTO_IPV6); 821 xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
816 822
817 rtnl_lock(); 823 rtnl_lock();
818 sit_destroy_tunnels(); 824 sit_destroy_tunnels();
@@ -826,7 +832,7 @@ static int __init sit_init(void)
826 832
827 printk(KERN_INFO "IPv6 over IPv4 tunneling driver\n"); 833 printk(KERN_INFO "IPv6 over IPv4 tunneling driver\n");
828 834
829 if (inet_add_protocol(&sit_protocol, IPPROTO_IPV6) < 0) { 835 if (xfrm4_tunnel_register(&sit_handler, AF_INET6) < 0) {
830 printk(KERN_INFO "sit init: Can't add protocol\n"); 836 printk(KERN_INFO "sit init: Can't add protocol\n");
831 return -EAGAIN; 837 return -EAGAIN;
832 } 838 }
@@ -848,7 +854,7 @@ static int __init sit_init(void)
848 err2: 854 err2:
849 free_netdev(ipip6_fb_tunnel_dev); 855 free_netdev(ipip6_fb_tunnel_dev);
850 err1: 856 err1:
851 inet_del_protocol(&sit_protocol, IPPROTO_IPV6); 857 xfrm4_tunnel_deregister(&sit_handler, AF_INET6);
852 goto out; 858 goto out;
853} 859}
854 860
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c
index 918d07dd121..23e2809878a 100644
--- a/net/ipv6/tunnel6.c
+++ b/net/ipv6/tunnel6.c
@@ -30,9 +30,10 @@
30#include <net/xfrm.h> 30#include <net/xfrm.h>
31 31
32static struct xfrm6_tunnel *tunnel6_handlers; 32static struct xfrm6_tunnel *tunnel6_handlers;
33static struct xfrm6_tunnel *tunnel46_handlers;
33static DEFINE_MUTEX(tunnel6_mutex); 34static DEFINE_MUTEX(tunnel6_mutex);
34 35
35int xfrm6_tunnel_register(struct xfrm6_tunnel *handler) 36int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family)
36{ 37{
37 struct xfrm6_tunnel **pprev; 38 struct xfrm6_tunnel **pprev;
38 int ret = -EEXIST; 39 int ret = -EEXIST;
@@ -40,7 +41,8 @@ int xfrm6_tunnel_register(struct xfrm6_tunnel *handler)
40 41
41 mutex_lock(&tunnel6_mutex); 42 mutex_lock(&tunnel6_mutex);
42 43
43 for (pprev = &tunnel6_handlers; *pprev; pprev = &(*pprev)->next) { 44 for (pprev = (family == AF_INET6) ? &tunnel6_handlers : &tunnel46_handlers;
45 *pprev; pprev = &(*pprev)->next) {
44 if ((*pprev)->priority > priority) 46 if ((*pprev)->priority > priority)
45 break; 47 break;
46 if ((*pprev)->priority == priority) 48 if ((*pprev)->priority == priority)
@@ -60,14 +62,15 @@ err:
60 62
61EXPORT_SYMBOL(xfrm6_tunnel_register); 63EXPORT_SYMBOL(xfrm6_tunnel_register);
62 64
63int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler) 65int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family)
64{ 66{
65 struct xfrm6_tunnel **pprev; 67 struct xfrm6_tunnel **pprev;
66 int ret = -ENOENT; 68 int ret = -ENOENT;
67 69
68 mutex_lock(&tunnel6_mutex); 70 mutex_lock(&tunnel6_mutex);
69 71
70 for (pprev = &tunnel6_handlers; *pprev; pprev = &(*pprev)->next) { 72 for (pprev = (family == AF_INET6) ? &tunnel6_handlers : &tunnel46_handlers;
73 *pprev; pprev = &(*pprev)->next) {
71 if (*pprev == handler) { 74 if (*pprev == handler) {
72 *pprev = handler->next; 75 *pprev = handler->next;
73 ret = 0; 76 ret = 0;
@@ -103,6 +106,25 @@ drop:
103 return 0; 106 return 0;
104} 107}
105 108
109static int tunnel46_rcv(struct sk_buff **pskb)
110{
111 struct sk_buff *skb = *pskb;
112 struct xfrm6_tunnel *handler;
113
114 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
115 goto drop;
116
117 for (handler = tunnel46_handlers; handler; handler = handler->next)
118 if (!handler->handler(skb))
119 return 0;
120
121 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, skb->dev);
122
123drop:
124 kfree_skb(skb);
125 return 0;
126}
127
106static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 128static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
107 int type, int code, int offset, __be32 info) 129 int type, int code, int offset, __be32 info)
108{ 130{
@@ -119,17 +141,30 @@ static struct inet6_protocol tunnel6_protocol = {
119 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 141 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
120}; 142};
121 143
144static struct inet6_protocol tunnel46_protocol = {
145 .handler = tunnel46_rcv,
146 .err_handler = tunnel6_err,
147 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
148};
149
122static int __init tunnel6_init(void) 150static int __init tunnel6_init(void)
123{ 151{
124 if (inet6_add_protocol(&tunnel6_protocol, IPPROTO_IPV6)) { 152 if (inet6_add_protocol(&tunnel6_protocol, IPPROTO_IPV6)) {
125 printk(KERN_ERR "tunnel6 init(): can't add protocol\n"); 153 printk(KERN_ERR "tunnel6 init(): can't add protocol\n");
126 return -EAGAIN; 154 return -EAGAIN;
127 } 155 }
156 if (inet6_add_protocol(&tunnel46_protocol, IPPROTO_IPIP)) {
157 printk(KERN_ERR "tunnel6 init(): can't add protocol\n");
158 inet6_del_protocol(&tunnel6_protocol, IPPROTO_IPV6);
159 return -EAGAIN;
160 }
128 return 0; 161 return 0;
129} 162}
130 163
131static void __exit tunnel6_fini(void) 164static void __exit tunnel6_fini(void)
132{ 165{
166 if (inet6_del_protocol(&tunnel46_protocol, IPPROTO_IPIP))
167 printk(KERN_ERR "tunnel6 close: can't remove protocol\n");
133 if (inet6_del_protocol(&tunnel6_protocol, IPPROTO_IPV6)) 168 if (inet6_del_protocol(&tunnel6_protocol, IPPROTO_IPV6))
134 printk(KERN_ERR "tunnel6 close: can't remove protocol\n"); 169 printk(KERN_ERR "tunnel6 close: can't remove protocol\n");
135} 170}
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index 25250147bdc..31f651f9509 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -40,7 +40,8 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
40 if (xfrm_nr == XFRM_MAX_DEPTH) 40 if (xfrm_nr == XFRM_MAX_DEPTH)
41 goto drop; 41 goto drop;
42 42
43 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi, nexthdr, AF_INET6); 43 x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi,
44 nexthdr != IPPROTO_IPIP ? nexthdr : IPPROTO_IPV6, AF_INET6);
44 if (x == NULL) 45 if (x == NULL)
45 goto drop; 46 goto drop;
46 spin_lock(&x->lock); 47 spin_lock(&x->lock);
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index fb0228772f0..ee4b84a33ff 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -339,17 +339,29 @@ static struct xfrm6_tunnel xfrm6_tunnel_handler = {
339 .priority = 2, 339 .priority = 2,
340}; 340};
341 341
342static struct xfrm6_tunnel xfrm46_tunnel_handler = {
343 .handler = xfrm6_tunnel_rcv,
344 .err_handler = xfrm6_tunnel_err,
345 .priority = 2,
346};
347
342static int __init xfrm6_tunnel_init(void) 348static int __init xfrm6_tunnel_init(void)
343{ 349{
344 if (xfrm_register_type(&xfrm6_tunnel_type, AF_INET6) < 0) 350 if (xfrm_register_type(&xfrm6_tunnel_type, AF_INET6) < 0)
345 return -EAGAIN; 351 return -EAGAIN;
346 352
347 if (xfrm6_tunnel_register(&xfrm6_tunnel_handler)) { 353 if (xfrm6_tunnel_register(&xfrm6_tunnel_handler, AF_INET6)) {
354 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
355 return -EAGAIN;
356 }
357 if (xfrm6_tunnel_register(&xfrm46_tunnel_handler, AF_INET)) {
358 xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);
348 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); 359 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
349 return -EAGAIN; 360 return -EAGAIN;
350 } 361 }
351 if (xfrm6_tunnel_spi_init() < 0) { 362 if (xfrm6_tunnel_spi_init() < 0) {
352 xfrm6_tunnel_deregister(&xfrm6_tunnel_handler); 363 xfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET);
364 xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);
353 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); 365 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
354 return -EAGAIN; 366 return -EAGAIN;
355 } 367 }
@@ -359,7 +371,8 @@ static int __init xfrm6_tunnel_init(void)
359static void __exit xfrm6_tunnel_fini(void) 371static void __exit xfrm6_tunnel_fini(void)
360{ 372{
361 xfrm6_tunnel_spi_fini(); 373 xfrm6_tunnel_spi_fini();
362 xfrm6_tunnel_deregister(&xfrm6_tunnel_handler); 374 xfrm6_tunnel_deregister(&xfrm46_tunnel_handler, AF_INET);
375 xfrm6_tunnel_deregister(&xfrm6_tunnel_handler, AF_INET6);
363 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6); 376 xfrm_unregister_type(&xfrm6_tunnel_type, AF_INET6);
364} 377}
365 378
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 135087d4213..396deb71480 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -71,8 +71,6 @@
71#include <asm/system.h> 71#include <asm/system.h>
72#include <asm/div64.h> 72#include <asm/div64.h>
73 73
74#define HFSC_DEBUG 1
75
76/* 74/*
77 * kernel internal service curve representation: 75 * kernel internal service curve representation:
78 * coordinates are given by 64 bit unsigned integers. 76 * coordinates are given by 64 bit unsigned integers.
@@ -211,17 +209,6 @@ do { \
211} while (0) 209} while (0)
212#endif 210#endif
213 211
214#if HFSC_DEBUG
215#define ASSERT(cond) \
216do { \
217 if (unlikely(!(cond))) \
218 printk("assertion %s failed at %s:%i (%s)\n", \
219 #cond, __FILE__, __LINE__, __FUNCTION__); \
220} while (0)
221#else
222#define ASSERT(cond)
223#endif /* HFSC_DEBUG */
224
225#define HT_INFINITY 0xffffffffffffffffULL /* infinite time value */ 212#define HT_INFINITY 0xffffffffffffffffULL /* infinite time value */
226 213
227 214
@@ -1492,7 +1479,7 @@ hfsc_schedule_watchdog(struct Qdisc *sch, u64 cur_time)
1492 if (next_time == 0 || next_time > q->root.cl_cfmin) 1479 if (next_time == 0 || next_time > q->root.cl_cfmin)
1493 next_time = q->root.cl_cfmin; 1480 next_time = q->root.cl_cfmin;
1494 } 1481 }
1495 ASSERT(next_time != 0); 1482 WARN_ON(next_time == 0);
1496 delay = next_time - cur_time; 1483 delay = next_time - cur_time;
1497 delay = PSCHED_US2JIFFIE(delay); 1484 delay = PSCHED_US2JIFFIE(delay);
1498 1485
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index c394b413f65..946b715db5e 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1550,7 +1550,7 @@ xfrm_state_ok(struct xfrm_tmpl *tmpl, struct xfrm_state *x,
1550 unsigned short family) 1550 unsigned short family)
1551{ 1551{
1552 if (xfrm_state_kern(x)) 1552 if (xfrm_state_kern(x))
1553 return tmpl->optional && !xfrm_state_addr_cmp(tmpl, x, family); 1553 return tmpl->optional && !xfrm_state_addr_cmp(tmpl, x, tmpl->encap_family);
1554 return x->id.proto == tmpl->id.proto && 1554 return x->id.proto == tmpl->id.proto &&
1555 (x->id.spi == tmpl->id.spi || !tmpl->id.spi) && 1555 (x->id.spi == tmpl->id.spi || !tmpl->id.spi) &&
1556 (x->props.reqid == tmpl->reqid || !tmpl->reqid) && 1556 (x->props.reqid == tmpl->reqid || !tmpl->reqid) &&