From f11b0f0eb2ea7562db63a01c60d398ec52d5ea46 Mon Sep 17 00:00:00 2001 From: Zhu Yi Date: Wed, 9 May 2007 13:41:52 +0800 Subject: [PATCH 01/24] [PATCH] mac80211: fail back to use associate from reassociate Some APs have strict checking between associate and reassociate. In a case when an AP is restarted during a connection, it denies the mac80211 reassoc request since this is a new association for the AP. To fix this problem, we need to check the status code against WLAN_STATUS_REASSOC_NO_ASSOC and clear ifsta->prev_bssid_set in handling the association failure response. Signed-off-by: Zhu Yi Signed-off-by: John W. Linville --- net/mac80211/ieee80211_sta.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c index 3e07e9d6fa42..dbac8583f394 100644 --- a/net/mac80211/ieee80211_sta.c +++ b/net/mac80211/ieee80211_sta.c @@ -1155,6 +1155,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct net_device *dev, if (status_code != WLAN_STATUS_SUCCESS) { printk(KERN_DEBUG "%s: AP denied association (code=%d)\n", dev->name, status_code); + if (status_code == WLAN_STATUS_REASSOC_NO_ASSOC) + ifsta->prev_bssid_set = 0; return; } From e8fdeca241e17dcc5b8f2465be8e1a6347c62fb9 Mon Sep 17 00:00:00 2001 From: Hong Liu Date: Thu, 17 May 2007 11:13:44 +0800 Subject: [PATCH 02/24] [PATCH] mac80211: fix memory leak when defrag fragments We forget to free all the fragments when defraging them into one packet. Signed-off-by: Hong Liu Signed-off-by: John W. Linville --- net/mac80211/ieee80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 6e36df67f8d5..145604abd08e 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c @@ -3278,8 +3278,10 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx) return TXRX_DROP; } } - while ((skb = __skb_dequeue(&entry->skb_list))) + while ((skb = __skb_dequeue(&entry->skb_list))) { memcpy(skb_put(rx->skb, skb->len), skb->data, skb->len); + dev_kfree_skb(skb); + } /* Complete frame has been reassembled - process it now */ rx->fragmented = 1; From 52fb24cd83bdd6a1dcbd4cf4b3f5cafb741b5552 Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Sun, 20 May 2007 09:44:00 -0700 Subject: [PATCH 03/24] [PATCH] mac80211: always set carrier status on open ieee80211_open should always set the carrier status since we may have set it to off before. Signed-off-by: Michael Wu Signed-off-by: John W. Linville --- net/mac80211/ieee80211.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 145604abd08e..4e84f24fd439 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c @@ -2474,6 +2474,8 @@ static int ieee80211_open(struct net_device *dev) if (sdata->type == IEEE80211_IF_TYPE_STA && !local->user_space_mlme) netif_carrier_off(dev); + else + netif_carrier_on(dev); netif_start_queue(dev); return 0; From 91fa558ba28b0014205f2c1a75b1cceb4298aa04 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 15 May 2007 16:14:40 -0400 Subject: [PATCH 04/24] [PATCH] mac80211: avoid null ptr deref in ieee80211_ibss_add_sta avoid sdata null pointer dereference in ieee80211_ibss_add_sta. Signed-off-by: John W. Linville --- net/mac80211/ieee80211_sta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c index dbac8583f394..9f30ae4c2ab3 100644 --- a/net/mac80211/ieee80211_sta.c +++ b/net/mac80211/ieee80211_sta.c @@ -2997,7 +2997,7 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev, { struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); struct sta_info *sta; - struct ieee80211_sub_if_data *sdata = NULL; + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); /* TODO: Could consider removing the least recently used entry and * allow new one to be added. */ From 4738d2fa5986d3717055d8ee14b2aad87c30f1e7 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 24 May 2007 20:59:26 -0700 Subject: [PATCH 05/24] [CASSINI]: Fix printk message typo. Signed-off-by: David S. Miller --- drivers/net/cassini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index 9fe3a38883ee..59b9943b077d 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c @@ -4920,7 +4920,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev, pci_cmd |= PCI_COMMAND_PARITY; pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); if (pci_set_mwi(pdev)) - printk(KERN_WARNING PFX "Could enable MWI for %s\n", + printk(KERN_WARNING PFX "Could not enable MWI for %s\n", pci_name(pdev)); /* From 01e67d08faa782f1a4d38de702331f5904def6ad Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 25 May 2007 00:41:38 -0700 Subject: [PATCH 06/24] [XFRM]: Allow XFRM_ACQ_EXPIRES to be tunable via sysctl. Signed-off-by: David S. Miller --- include/net/xfrm.h | 1 - net/core/sysctl_net_core.c | 9 +++++++++ net/xfrm/xfrm_state.c | 15 +++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 39ef925d39dd..90185e8b335e 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -237,7 +237,6 @@ extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo); extern void km_policy_notify(struct xfrm_policy *xp, int dir, struct km_event *c); extern void km_state_notify(struct xfrm_state *x, struct km_event *c); -#define XFRM_ACQ_EXPIRES 30 struct xfrm_tmpl; extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index f34aca041a25..6d5ea9762040 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -25,6 +25,7 @@ extern int sysctl_core_destroy_delay; extern u32 sysctl_xfrm_aevent_etime; extern u32 sysctl_xfrm_aevent_rseqth; extern int sysctl_xfrm_larval_drop; +extern u32 sysctl_xfrm_acq_expires; #endif ctl_table core_table[] = { @@ -127,6 +128,14 @@ ctl_table core_table[] = { .mode = 0644, .proc_handler = &proc_dointvec }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "xfrm_acq_expires", + .data = &sysctl_xfrm_acq_expires, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec + }, #endif /* CONFIG_XFRM */ #endif /* CONFIG_NET */ { diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 9955ff4da0a2..372f06eb8bb7 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -21,18 +21,21 @@ #include #include #include +#include #include "xfrm_hash.h" struct sock *xfrm_nl; EXPORT_SYMBOL(xfrm_nl); -u32 sysctl_xfrm_aevent_etime = XFRM_AE_ETIME; +u32 sysctl_xfrm_aevent_etime __read_mostly = XFRM_AE_ETIME; EXPORT_SYMBOL(sysctl_xfrm_aevent_etime); -u32 sysctl_xfrm_aevent_rseqth = XFRM_AE_SEQT_SIZE; +u32 sysctl_xfrm_aevent_rseqth __read_mostly = XFRM_AE_SEQT_SIZE; EXPORT_SYMBOL(sysctl_xfrm_aevent_rseqth); +u32 sysctl_xfrm_acq_expires __read_mostly = 30; + /* Each xfrm_state may be linked to two tables: 1. Hash table by (spi,daddr,ah/esp) to find SA by SPI. (input,ctl) @@ -622,8 +625,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, h = xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto, family); hlist_add_head(&x->byspi, xfrm_state_byspi+h); } - x->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES; - x->timer.expires = jiffies + XFRM_ACQ_EXPIRES*HZ; + x->lft.hard_add_expires_seconds = sysctl_xfrm_acq_expires; + x->timer.expires = jiffies + sysctl_xfrm_acq_expires*HZ; add_timer(&x->timer); xfrm_state_num++; xfrm_hash_grow_check(x->bydst.next != NULL); @@ -772,9 +775,9 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re x->props.family = family; x->props.mode = mode; x->props.reqid = reqid; - x->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES; + x->lft.hard_add_expires_seconds = sysctl_xfrm_acq_expires; xfrm_state_hold(x); - x->timer.expires = jiffies + XFRM_ACQ_EXPIRES*HZ; + x->timer.expires = jiffies + sysctl_xfrm_acq_expires*HZ; add_timer(&x->timer); hlist_add_head(&x->bydst, xfrm_state_bydst+h); h = xfrm_src_hash(daddr, saddr, family); From aad0e0b9b6e4f7085d5e2ec4b5bb59ffecd8b1fb Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 25 May 2007 00:42:49 -0700 Subject: [PATCH 07/24] [XFRM]: xfrm_larval_drop sysctl should be __read_mostly. Signed-off-by: David S. Miller --- net/xfrm/xfrm_policy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index b8bab89616a0..64a375178c5f 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -26,10 +26,11 @@ #include #include #include +#include #include "xfrm_hash.h" -int sysctl_xfrm_larval_drop; +int sysctl_xfrm_larval_drop __read_mostly; DEFINE_MUTEX(xfrm_cfg_mutex); EXPORT_SYMBOL(xfrm_cfg_mutex); From 144466bdf8c479ae36678ace7a3b8e8b748df6f6 Mon Sep 17 00:00:00 2001 From: Kazunori MIYAZAWA Date: Fri, 25 May 2007 01:22:25 -0700 Subject: [PATCH 08/24] [IPSEC]: Fix IPv6 AH calculation in outbound Signed-off-by: Kazunori MIYAZAWA Signed-off-by: David S. Miller --- net/ipv6/ah6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index b696c8401200..128f94c79c64 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -247,7 +247,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb) memcpy(tmp_base, top_iph, sizeof(tmp_base)); tmp_ext = NULL; - extlen = skb_transport_offset(skb) + sizeof(struct ipv6hdr); + extlen = skb_transport_offset(skb) - sizeof(struct ipv6hdr); if (extlen) { extlen += sizeof(*tmp_ext); tmp_ext = kmalloc(extlen, GFP_ATOMIC); From 7ebba6d14f8d63cad583bf1cc0330b601d5a8171 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Tue, 29 May 2007 01:13:24 -0700 Subject: [PATCH 09/24] [IPV6] ROUTE: No longer handle ::/0 specially. We do not need to handle ::/0 routes specially any longer. This should fix BUG #8349. Signed-off-by: YOSHIFUJI Hideaki Acked-by: Yuji Sekiya Signed-off-by: David S. Miller --- net/ipv6/ip6_fib.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index ca08ee88d07f..154033fdaeb7 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -619,14 +619,6 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, ins = &fn->leaf; - if (fn->fn_flags&RTN_TL_ROOT && - fn->leaf == &ip6_null_entry && - !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){ - fn->leaf = rt; - rt->u.dst.rt6_next = NULL; - goto out; - } - for (iter = fn->leaf; iter; iter=iter->u.dst.rt6_next) { /* * Search for duplicates From 83f03fa5adbad0a829424241ad24ef9e4b4ba585 Mon Sep 17 00:00:00 2001 From: Jerome Borsboom Date: Tue, 29 May 2007 12:59:54 -0700 Subject: [PATCH 10/24] [NET]: parse ip:port strings correctly in in4_pton in4_pton converts a textual representation of an ip4 address into an integer representation. However, when the textual representation is of in the form ip:port, e.g. 192.168.1.1:5060, and 'delim' is set to -1, the function bails out with an error when reading the colon. It makes sense to allow the colon as a delimiting character without explicitly having to set it through the 'delim' variable as there can be no ambiguity in the point where the ip address is completely parsed. This function is indeed called from nf_conntrack_sip.c in this way to parse textual ip:port combinations which fails due to the reason stated above. Signed-off-by: Jerome Borsboom Signed-off-by: David S. Miller --- net/core/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/utils.c b/net/core/utils.c index adecfd281ae9..2030bb8c2d30 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -139,16 +139,16 @@ int in4_pton(const char *src, int srclen, while(1) { int c; c = xdigit2bin(srclen > 0 ? *s : '\0', delim); - if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM))) { + if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK))) { goto out; } - if (c & (IN6PTON_DOT | IN6PTON_DELIM)) { + if (c & (IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK)) { if (w == 0) goto out; *d++ = w & 0xff; w = 0; i++; - if (c & IN6PTON_DELIM) { + if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) { if (i != 4) goto out; break; From f282d45cb496e3960046afd3d5f241265eda6fde Mon Sep 17 00:00:00 2001 From: Kazunori MIYAZAWA Date: Tue, 29 May 2007 13:03:17 -0700 Subject: [PATCH 11/24] [IPSEC]: Fix panic when using inter address familiy IPsec on loopback. Signed-off-by: Kazunori MIYAZAWA Signed-off-by: David S. Miller --- net/ipv4/xfrm4_input.c | 6 ++---- net/ipv4/xfrm4_mode_tunnel.c | 2 ++ net/ipv6/xfrm6_input.c | 6 ++---- net/ipv6/xfrm6_mode_tunnel.c | 1 + 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c index 5ceca951d73f..fa1902dc81b8 100644 --- a/net/ipv4/xfrm4_input.c +++ b/net/ipv4/xfrm4_input.c @@ -139,10 +139,8 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type) nf_reset(skb); if (decaps) { - if (!(skb->dev->flags&IFF_LOOPBACK)) { - dst_release(skb->dst); - skb->dst = NULL; - } + dst_release(skb->dst); + skb->dst = NULL; netif_rx(skb); return 0; } else { diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c index a2f2e6a5ec5d..9963700e74c1 100644 --- a/net/ipv4/xfrm4_mode_tunnel.c +++ b/net/ipv4/xfrm4_mode_tunnel.c @@ -85,6 +85,8 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) top_iph->saddr = x->props.saddr.a4; top_iph->daddr = x->id.daddr.a4; + skb->protocol = htons(ETH_P_IP); + memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options)); return 0; } diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c index d7ed8aa56ec1..c858537cec4b 100644 --- a/net/ipv6/xfrm6_input.c +++ b/net/ipv6/xfrm6_input.c @@ -104,10 +104,8 @@ int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi) nf_reset(skb); if (decaps) { - if (!(skb->dev->flags&IFF_LOOPBACK)) { - dst_release(skb->dst); - skb->dst = NULL; - } + dst_release(skb->dst); + skb->dst = NULL; netif_rx(skb); return -1; } else { diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c index a6c0cdf46ad6..9fc95bc6509f 100644 --- a/net/ipv6/xfrm6_mode_tunnel.c +++ b/net/ipv6/xfrm6_mode_tunnel.c @@ -80,6 +80,7 @@ static int xfrm6_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT); ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr); ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); + skb->protocol = htons(ETH_P_IPV6); return 0; } From ddc31ce311b65fc3c30ec9ca5baf688a882260bc Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 29 May 2007 13:06:51 -0700 Subject: [PATCH 12/24] [IPV4]: Kill references to bogus non-existent CONFIG_IP_NOSIOCRT Signed-off-by: David S. Miller --- net/ipv4/fib_frontend.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 837f2957fa83..9ad1f6252a97 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -250,8 +250,6 @@ e_inval: return -EINVAL; } -#ifndef CONFIG_IP_NOSIOCRT - static inline __be32 sk_extract_addr(struct sockaddr *addr) { return ((struct sockaddr_in *) addr)->sin_addr.s_addr; @@ -443,15 +441,6 @@ int ip_rt_ioctl(unsigned int cmd, void __user *arg) return -EINVAL; } -#else - -int ip_rt_ioctl(unsigned int cmd, void *arg) -{ - return -EINVAL; -} - -#endif - struct nla_policy rtm_ipv4_policy[RTA_MAX+1] __read_mostly = { [RTA_DST] = { .type = NLA_U32 }, [RTA_SRC] = { .type = NLA_U32 }, From a2efcfa04865eaaa88b870f4babf12f4c1fc4f83 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 29 May 2007 13:12:50 -0700 Subject: [PATCH 13/24] [AF_PACKET]: Kill bogus CONFIG_PACKET_MULTICAST It is unconditionally set by af_packet.c, not by the Kconfig subsystem, so just kill it off. Signed-off-by: David S. Miller --- net/packet/af_packet.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 02e401cd683f..99b55e641e8d 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -85,20 +85,6 @@ #define CONFIG_SOCK_PACKET 1 -/* - Proposed replacement for SIOC{ADD,DEL}MULTI and - IFF_PROMISC, IFF_ALLMULTI flags. - - It is more expensive, but I believe, - it is really correct solution: reentereble, safe and fault tolerant. - - IFF_PROMISC/IFF_ALLMULTI/SIOC{ADD/DEL}MULTI are faked by keeping - reference count and global flag, so that real status is - (gflag|(count != 0)), so that we can use obsolete faulty interface - not harming clever users. - */ -#define CONFIG_PACKET_MULTICAST 1 - /* Assumptions: - if device has no dev->hard_header routine, it adds and removes ll header @@ -159,7 +145,6 @@ static atomic_t packet_socks_nr; /* Private packet socket structures. */ -#ifdef CONFIG_PACKET_MULTICAST struct packet_mclist { struct packet_mclist *next; @@ -179,7 +164,7 @@ struct packet_mreq_max unsigned short mr_alen; unsigned char mr_address[MAX_ADDR_LEN]; }; -#endif + #ifdef CONFIG_PACKET_MMAP static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing); #endif @@ -205,9 +190,7 @@ struct packet_sock { origdev:1; int ifindex; /* bound device */ __be16 num; -#ifdef CONFIG_PACKET_MULTICAST struct packet_mclist *mclist; -#endif #ifdef CONFIG_PACKET_MMAP atomic_t mapped; unsigned int pg_vec_order; @@ -851,9 +834,7 @@ static int packet_release(struct socket *sock) __sock_put(sk); } -#ifdef CONFIG_PACKET_MULTICAST packet_flush_mclist(sk); -#endif #ifdef CONFIG_PACKET_MMAP if (po->pg_vec) { @@ -1221,7 +1202,6 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr, return 0; } -#ifdef CONFIG_PACKET_MULTICAST static void packet_dev_mc(struct net_device *dev, struct packet_mclist *i, int what) { switch (i->type) { @@ -1349,7 +1329,6 @@ static void packet_flush_mclist(struct sock *sk) } rtnl_unlock(); } -#endif static int packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) @@ -1362,7 +1341,6 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv return -ENOPROTOOPT; switch(optname) { -#ifdef CONFIG_PACKET_MULTICAST case PACKET_ADD_MEMBERSHIP: case PACKET_DROP_MEMBERSHIP: { @@ -1383,7 +1361,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv ret = packet_mc_drop(sk, &mreq); return ret; } -#endif + #ifdef CONFIG_PACKET_MMAP case PACKET_RX_RING: { @@ -1506,11 +1484,10 @@ static int packet_notifier(struct notifier_block *this, unsigned long msg, void switch (msg) { case NETDEV_UNREGISTER: -#ifdef CONFIG_PACKET_MULTICAST if (po->mclist) packet_dev_mclist(dev, po->mclist, -1); - // fallthrough -#endif + /* fallthrough */ + case NETDEV_DOWN: if (dev->ifindex == po->ifindex) { spin_lock(&po->bind_lock); From 8c7fc03e27167425a1396320da43533462556b0c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 29 May 2007 13:15:41 -0700 Subject: [PATCH 14/24] [IPV6]: Fix build warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit net/ipv6/ip6_fib.c: In function ‘fib6_add_rt2node’: net/ipv6/ip6_fib.c:661: warning: label ‘out’ defined but not used Signed-off-by: David S. Miller --- net/ipv6/ip6_fib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 154033fdaeb7..662a7d9681fd 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -658,7 +658,6 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, * insert node */ -out: rt->u.dst.rt6_next = iter; *ins = rt; rt->rt6i_node = fn; From be02097cf6342eb0426833f54c95e0fb4c9bca45 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 29 May 2007 13:16:31 -0700 Subject: [PATCH 15/24] [AF_PACKET]: Kill CONFIG_PACKET_SOCKET. Always set, but af_packet.c, not by the Kconfig subsystem, so just get rid of it. Signed-off-by: David S. Miller --- net/packet/af_packet.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 99b55e641e8d..f8b83014ccca 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -83,8 +83,6 @@ #include #endif -#define CONFIG_SOCK_PACKET 1 - /* Assumptions: - if device has no dev->hard_header routine, it adds and removes ll header @@ -246,7 +244,6 @@ static void packet_sock_destruct(struct sock *sk) static const struct proto_ops packet_ops; -#ifdef CONFIG_SOCK_PACKET static const struct proto_ops packet_ops_spkt; static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) @@ -418,7 +415,6 @@ out_unlock: dev_put(dev); return err; } -#endif static inline unsigned int run_filter(struct sk_buff *skb, struct sock *sk, unsigned int res) @@ -917,8 +913,6 @@ out_unlock: * Bind a packet socket to a device */ -#ifdef CONFIG_SOCK_PACKET - static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sock *sk=sock->sk; @@ -941,7 +935,6 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add } return err; } -#endif static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { @@ -993,11 +986,8 @@ static int packet_create(struct socket *sock, int protocol) if (!capable(CAP_NET_RAW)) return -EPERM; - if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW -#ifdef CONFIG_SOCK_PACKET - && sock->type != SOCK_PACKET -#endif - ) + if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW && + sock->type != SOCK_PACKET) return -ESOCKTNOSUPPORT; sock->state = SS_UNCONNECTED; @@ -1008,10 +998,9 @@ static int packet_create(struct socket *sock, int protocol) goto out; sock->ops = &packet_ops; -#ifdef CONFIG_SOCK_PACKET if (sock->type == SOCK_PACKET) sock->ops = &packet_ops_spkt; -#endif + sock_init_data(sock, sk); po = pkt_sk(sk); @@ -1027,10 +1016,10 @@ static int packet_create(struct socket *sock, int protocol) spin_lock_init(&po->bind_lock); po->prot_hook.func = packet_rcv; -#ifdef CONFIG_SOCK_PACKET + if (sock->type == SOCK_PACKET) po->prot_hook.func = packet_rcv_spkt; -#endif + po->prot_hook.af_packet_priv = sk; if (proto) { @@ -1150,7 +1139,6 @@ out: return err; } -#ifdef CONFIG_SOCK_PACKET static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer) { @@ -1171,7 +1159,6 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr, return 0; } -#endif static int packet_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_len, int peer) @@ -1833,7 +1820,6 @@ out: #endif -#ifdef CONFIG_SOCK_PACKET static const struct proto_ops packet_ops_spkt = { .family = PF_PACKET, .owner = THIS_MODULE, @@ -1854,7 +1840,6 @@ static const struct proto_ops packet_ops_spkt = { .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, }; -#endif static const struct proto_ops packet_ops = { .family = PF_PACKET, From 4e07a91c37c69ec1647c218214591ee4fe3408fe Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 29 May 2007 13:17:47 -0700 Subject: [PATCH 16/24] [SOCK]: Shrink struct sock by 8 bytes on 64-bit. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/sock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/sock.h b/include/net/sock.h index 689b886038da..dfeb8b13024f 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -218,13 +218,13 @@ struct sock { atomic_t sk_rmem_alloc; atomic_t sk_wmem_alloc; atomic_t sk_omem_alloc; + int sk_sndbuf; struct sk_buff_head sk_receive_queue; struct sk_buff_head sk_write_queue; struct sk_buff_head sk_async_wait_queue; int sk_wmem_queued; int sk_forward_alloc; gfp_t sk_allocation; - int sk_sndbuf; int sk_route_caps; int sk_gso_type; int sk_rcvlowat; From e4fd5da39f99d5921dda1fe3d93652fbd925fbfd Mon Sep 17 00:00:00 2001 From: Pavel Emelianov Date: Tue, 29 May 2007 13:19:18 -0700 Subject: [PATCH 17/24] [TCP]: Consolidate checking for tcp orphan count being too big. tcp_out_of_resources() and tcp_close() perform the same checking of number of orphan sockets. Move this code into common place. Signed-off-by: Pavel Emelianov Signed-off-by: David S. Miller --- include/net/tcp.h | 6 ++++++ net/ipv4/tcp.c | 5 ++--- net/ipv4/tcp_timer.c | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index e22b4f0305a3..a8af9ae00177 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -254,6 +254,12 @@ static inline int between(__u32 seq1, __u32 seq2, __u32 seq3) return seq3 - seq2 >= seq1 - seq2; } +static inline int tcp_too_many_orphans(struct sock *sk, int num) +{ + return (num > sysctl_tcp_max_orphans) || + (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && + atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]); +} extern struct proto tcp_prot; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index bd4c295f5d79..766314505c09 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1674,9 +1674,8 @@ adjudge_to_death: } if (sk->sk_state != TCP_CLOSE) { sk_stream_mem_reclaim(sk); - if (atomic_read(sk->sk_prot->orphan_count) > sysctl_tcp_max_orphans || - (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && - atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2])) { + if (tcp_too_many_orphans(sk, + atomic_read(sk->sk_prot->orphan_count))) { if (net_ratelimit()) printk(KERN_INFO "TCP: too many of orphaned " "sockets\n"); diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 2ca97b20929d..e61340150ba6 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -78,9 +78,7 @@ static int tcp_out_of_resources(struct sock *sk, int do_reset) if (sk->sk_err_soft) orphans <<= 1; - if (orphans >= sysctl_tcp_max_orphans || - (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && - atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2])) { + if (tcp_too_many_orphans(sk, orphans)) { if (net_ratelimit()) printk(KERN_INFO "Out of socket memory\n"); From b0ba66671a92f7d12fdbc42592d36e678f713efc Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 29 May 2007 13:22:52 -0700 Subject: [PATCH 18/24] [NET] napi: Call __netif_rx_complete in netif_rx_complete This patch kills a little bit of code duplication between the two variants of netif_rx_complete. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- include/linux/netdevice.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f671cd2f133f..3a70f553b28f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -910,6 +910,17 @@ static inline int netif_rx_reschedule(struct net_device *dev, int undo) return 0; } +/* same as netif_rx_complete, except that local_irq_save(flags) + * has already been issued + */ +static inline void __netif_rx_complete(struct net_device *dev) +{ + BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state)); + list_del(&dev->poll_list); + smp_mb__before_clear_bit(); + clear_bit(__LINK_STATE_RX_SCHED, &dev->state); +} + /* Remove interface from poll list: it must be in the poll list * on current cpu. This primitive is called by dev->poll(), when * it completes the work. The device cannot be out of poll list at this @@ -920,10 +931,7 @@ static inline void netif_rx_complete(struct net_device *dev) unsigned long flags; local_irq_save(flags); - BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state)); - list_del(&dev->poll_list); - smp_mb__before_clear_bit(); - clear_bit(__LINK_STATE_RX_SCHED, &dev->state); + __netif_rx_complete(dev); local_irq_restore(flags); } @@ -940,17 +948,6 @@ static inline void netif_poll_enable(struct net_device *dev) clear_bit(__LINK_STATE_RX_SCHED, &dev->state); } -/* same as netif_rx_complete, except that local_irq_save(flags) - * has already been issued - */ -static inline void __netif_rx_complete(struct net_device *dev) -{ - BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state)); - list_del(&dev->poll_list); - smp_mb__before_clear_bit(); - clear_bit(__LINK_STATE_RX_SCHED, &dev->state); -} - static inline void netif_tx_lock(struct net_device *dev) { spin_lock(&dev->_xmit_lock); From 4540250be1d724943a55eb9668e6edc1aaae28c4 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Tue, 29 May 2007 13:23:34 -0700 Subject: [PATCH 19/24] [IPV6] ADDRCONF: Fix conflicts in DEVCONF_xxx constant. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- include/linux/ipv6.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 09ea01a8a99c..648bd1f0912d 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -209,9 +209,8 @@ enum { DEVCONF_RTR_PROBE_INTERVAL, DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN, DEVCONF_PROXY_NDP, - __DEVCONF_OPTIMISTIC_DAD, - DEVCONF_ACCEPT_SOURCE_ROUTE, DEVCONF_OPTIMISTIC_DAD, + DEVCONF_ACCEPT_SOURCE_ROUTE, DEVCONF_MAX }; From 63313494c4419bd5d60b4f3ef8970a98525ac9d3 Mon Sep 17 00:00:00 2001 From: Sangtae Ha Date: Tue, 29 May 2007 13:24:11 -0700 Subject: [PATCH 20/24] [TCP] tcp_probe: a trivial fix for mismatched number of printl arguments. Just a fix to correct the number of printl arguments. Now, srtt is logging correctly. Signed-off-by: Sangtae Ha Signed-off-by: David S. Miller --- net/ipv4/tcp_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c index 3938d5dbdf20..1b72c55d336f 100644 --- a/net/ipv4/tcp_probe.c +++ b/net/ipv4/tcp_probe.c @@ -95,7 +95,7 @@ static int jtcp_rcv_established(struct sock *sk, struct sk_buff *skb, /* Only update if port matches */ if ((port == 0 || ntohs(inet->dport) == port || ntohs(inet->sport) == port) && (full || tp->snd_cwnd != tcpw.lastcwnd)) { - printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d %#x %#x %u %u %u\n", + printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d %#x %#x %u %u %u %u\n", NIPQUAD(inet->saddr), ntohs(inet->sport), NIPQUAD(inet->daddr), ntohs(inet->dport), skb->len, tp->snd_nxt, tp->snd_una, From 67403754bceda484a62a697878ff20a0e8d3aae6 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 29 May 2007 13:24:51 -0700 Subject: [PATCH 21/24] [TCP] tcp_probe: use GCC printf attribute The function in tcp_probe is printf like, use GCC to check the args. Sighed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/tcp_probe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c index 1b72c55d336f..760165a0800c 100644 --- a/net/ipv4/tcp_probe.c +++ b/net/ipv4/tcp_probe.c @@ -80,7 +80,8 @@ static void printl(const char *fmt, ...) kfifo_put(tcpw.fifo, tbuf, len); wake_up(&tcpw.wait); -} +} __attribute__ ((format (printf, 1, 2))); + /* * Hook inserted to be called before each receive packet. From 071f7722686151817855195654f16a0b65d9473c Mon Sep 17 00:00:00 2001 From: Baruch Even Date: Thu, 31 May 2007 01:20:45 -0700 Subject: [PATCH 22/24] [BRIDGE]: Reduce frequency of forwarding cleanup timer in bridge. The bridge cleanup timer is fired 10 times a second for timers that are at least 15 seconds ahead in time and that are not critical to be cleaned asap. This patch calculates the next time to run the timer as the minimum of all timers or a minimum based on the current state. Signed-off-by: Baruch Even Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_fdb.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 91b017016d5b..3fc697293819 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -121,6 +121,7 @@ void br_fdb_cleanup(unsigned long _data) { struct net_bridge *br = (struct net_bridge *)_data; unsigned long delay = hold_time(br); + unsigned long next_timer = jiffies + br->forward_delay; int i; spin_lock_bh(&br->hash_lock); @@ -129,14 +130,21 @@ void br_fdb_cleanup(unsigned long _data) struct hlist_node *h, *n; hlist_for_each_entry_safe(f, h, n, &br->hash[i], hlist) { - if (!f->is_static && - time_before_eq(f->ageing_timer + delay, jiffies)) + unsigned long this_timer; + if (f->is_static) + continue; + this_timer = f->ageing_timer + delay; + if (time_before_eq(this_timer, jiffies)) fdb_delete(f); + else if (this_timer < next_timer) + next_timer = this_timer; } } spin_unlock_bh(&br->hash_lock); - mod_timer(&br->gc_timer, jiffies + HZ/10); + /* Add HZ/4 to ensure we round the jiffies upwards to be after the next + * timer, otherwise we might round down and will have no-op run. */ + mod_timer(&br->gc_timer, round_jiffies(next_timer + HZ/4)); } /* Completely flush all dynamic entries in forwarding database.*/ From 9a834b87c5544c347fd788cd9d4eb276402ab54a Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 31 May 2007 01:21:39 -0700 Subject: [PATCH 23/24] [BRIDGE]: Round off STP perodic timers. Peroidic STP timers don't have to be exact. The hold timer runs at 1HZ, and the hello timer normally runs at 2HZ; save power by aligning it them to next second. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_stp.c | 3 ++- net/bridge/br_stp_timer.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c index 0e035d6162cc..e38034aa56f5 100644 --- a/net/bridge/br_stp.c +++ b/net/bridge/br_stp.c @@ -178,7 +178,8 @@ void br_transmit_config(struct net_bridge_port *p) br_send_config_bpdu(p, &bpdu); p->topology_change_ack = 0; p->config_pending = 0; - mod_timer(&p->hold_timer, jiffies + BR_HOLD_TIME); + mod_timer(&p->hold_timer, + round_jiffies(jiffies + BR_HOLD_TIME)); } } diff --git a/net/bridge/br_stp_timer.c b/net/bridge/br_stp_timer.c index 24e0ca4a3131..77f5255e6915 100644 --- a/net/bridge/br_stp_timer.c +++ b/net/bridge/br_stp_timer.c @@ -42,7 +42,7 @@ static void br_hello_timer_expired(unsigned long arg) if (br->dev->flags & IFF_UP) { br_config_bpdu_generation(br); - mod_timer(&br->hello_timer, jiffies + br->hello_time); + mod_timer(&br->hello_timer, round_jiffies(jiffies + br->hello_time)); } spin_unlock(&br->lock); } From 85553ddafc5415534bcbe63ffa3af6506e6a754e Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 31 May 2007 01:34:55 -0700 Subject: [PATCH 24/24] [IPSEC]: Add xfrm_sysctl.txt. And use it to document new xfrm_acq_expires sysctl. Signed-off-by: David S. Miller --- Documentation/networking/xfrm_sysctl.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Documentation/networking/xfrm_sysctl.txt diff --git a/Documentation/networking/xfrm_sysctl.txt b/Documentation/networking/xfrm_sysctl.txt new file mode 100644 index 000000000000..5bbd16792fe1 --- /dev/null +++ b/Documentation/networking/xfrm_sysctl.txt @@ -0,0 +1,4 @@ +/proc/sys/net/core/xfrm_* Variables: + +xfrm_acq_expires - INTEGER + default 30 - hard timeout in seconds for acquire requests