Skip to content

Commit e89970a

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: netfilter: nf_conntrack_sctp: fix sparse warnings netfilter: nf_nat_sip: c= is optional for session netfilter: xt_TCPMSS: collapse tcpmss_reverse_mtu{4,6} into one function netfilter: nfnetlink_log: send complete hardware header netfilter: xt_time: fix time's time_mt()'s use of do_div() netfilter: accounting rework: ct_extend + 64bit counters (v4) netlink: add NLA_PUT_BE64 macro netfilter: nf_nat_core: eliminate useless find_appropriate_src for IP_NAT_RANGE_PROTO_RANDOM hdlcdrv: Fix CRC calculation. Revert "pkt_sched: Make default qdisc nonshared-multiqueue safe." net: In __netif_schedule() use WARN_ON instead of BUG_ON net: Improve simple_tx_hash(). pkt_sched: Remove unused variable skb in dev_deactivate_queue function. sunhme: Remove stop/wake TX queue calls in set-multicast-list handler. ucc_geth: do not touch net queue in adjust_link phylib callback gianfar: do not touch net queue in adjust_link phylib callback atl1: Do not wake queue before queue has been started.
2 parents 443bd1c + 5547cd0 commit e89970a

30 files changed

+411
-184
lines changed

Documentation/feature-removal-schedule.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,13 @@ When: After the only user (hal) has seen a release with the patches
336336
Why: Over 1K .text/.data size reduction, data is available in other
337337
ways (ioctls)
338338
Who: Johannes Berg <johannes@sipsolutions.net>
339+
340+
---------------------------
341+
342+
What: CONFIG_NF_CT_ACCT
343+
When: 2.6.29
344+
Why: Accounting can now be enabled/disabled without kernel recompilation.
345+
Currently used only to set a default value for a feature that is also
346+
controlled by a kernel/module/sysfs/sysctl parameter.
347+
Who: Krzysztof Piotr Oledzki <ole@ans.pl>
348+

Documentation/kernel-parameters.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,13 @@ and is between 256 and 4096 characters. It is defined in the file
12791279
This usage is only documented in each driver source
12801280
file if at all.
12811281

1282+
nf_conntrack.acct=
1283+
[NETFILTER] Enable connection tracking flow accounting
1284+
0 to disable accounting
1285+
1 to enable accounting
1286+
Default value depends on CONFIG_NF_CT_ACCT that is
1287+
going to be removed in 2.6.29.
1288+
12821289
nfsaddrs= [NFS]
12831290
See Documentation/filesystems/nfsroot.txt.
12841291

drivers/net/atlx/atl1.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,6 @@ static u32 atl1_check_link(struct atl1_adapter *adapter)
13081308
dev_info(&adapter->pdev->dev, "link is down\n");
13091309
adapter->link_speed = SPEED_0;
13101310
netif_carrier_off(netdev);
1311-
netif_stop_queue(netdev);
13121311
}
13131312
return 0;
13141313
}
@@ -1358,7 +1357,6 @@ static u32 atl1_check_link(struct atl1_adapter *adapter)
13581357
if (!netif_carrier_ok(netdev)) {
13591358
/* Link down -> Up */
13601359
netif_carrier_on(netdev);
1361-
netif_wake_queue(netdev);
13621360
}
13631361
return 0;
13641362
}
@@ -2627,6 +2625,7 @@ static s32 atl1_up(struct atl1_adapter *adapter)
26272625
mod_timer(&adapter->watchdog_timer, jiffies);
26282626
atlx_irq_enable(adapter);
26292627
atl1_check_link(adapter);
2628+
netif_start_queue(netdev);
26302629
return 0;
26312630

26322631
err_up:

drivers/net/gianfar.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,6 @@ static void adjust_link(struct net_device *dev)
17251725
if (!priv->oldlink) {
17261726
new_state = 1;
17271727
priv->oldlink = 1;
1728-
netif_tx_schedule_all(dev);
17291728
}
17301729
} else if (priv->oldlink) {
17311730
new_state = 1;

drivers/net/hamradio/hdlcdrv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
static inline void append_crc_ccitt(unsigned char *buffer, int len)
8989
{
9090
unsigned int crc = crc_ccitt(0xffff, buffer, len) ^ 0xffff;
91+
buffer += len;
9192
*buffer++ = crc;
9293
*buffer++ = crc >> 8;
9394
}

drivers/net/sunhme.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,8 +2377,6 @@ static void happy_meal_set_multicast(struct net_device *dev)
23772377

23782378
spin_lock_irq(&hp->happy_lock);
23792379

2380-
netif_stop_queue(dev);
2381-
23822380
if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 64)) {
23832381
hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff);
23842382
hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff);
@@ -2410,8 +2408,6 @@ static void happy_meal_set_multicast(struct net_device *dev)
24102408
hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]);
24112409
}
24122410

2413-
netif_wake_queue(dev);
2414-
24152411
spin_unlock_irq(&hp->happy_lock);
24162412
}
24172413

drivers/net/ucc_geth.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,6 @@ static void adjust_link(struct net_device *dev)
15881588
if (!ugeth->oldlink) {
15891589
new_state = 1;
15901590
ugeth->oldlink = 1;
1591-
netif_tx_schedule_all(dev);
15921591
}
15931592
} else if (ugeth->oldlink) {
15941593
new_state = 1;

include/linux/netfilter/nf_conntrack_common.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ enum ip_conntrack_events
122122
IPCT_NATINFO_BIT = 10,
123123
IPCT_NATINFO = (1 << IPCT_NATINFO_BIT),
124124

125-
/* Counter highest bit has been set */
125+
/* Counter highest bit has been set, unused */
126126
IPCT_COUNTER_FILLING_BIT = 11,
127127
IPCT_COUNTER_FILLING = (1 << IPCT_COUNTER_FILLING_BIT),
128128

@@ -145,12 +145,6 @@ enum ip_conntrack_expect_events {
145145
};
146146

147147
#ifdef __KERNEL__
148-
struct ip_conntrack_counter
149-
{
150-
u_int32_t packets;
151-
u_int32_t bytes;
152-
};
153-
154148
struct ip_conntrack_stat
155149
{
156150
unsigned int searched;

include/linux/netfilter/nfnetlink_conntrack.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ enum ctattr_protoinfo_sctp {
115115

116116
enum ctattr_counters {
117117
CTA_COUNTERS_UNSPEC,
118-
CTA_COUNTERS_PACKETS, /* old 64bit counters */
119-
CTA_COUNTERS_BYTES, /* old 64bit counters */
120-
CTA_COUNTERS32_PACKETS,
121-
CTA_COUNTERS32_BYTES,
118+
CTA_COUNTERS_PACKETS, /* 64bit counters */
119+
CTA_COUNTERS_BYTES, /* 64bit counters */
120+
CTA_COUNTERS32_PACKETS, /* old 32bit counters, unused */
121+
CTA_COUNTERS32_BYTES, /* old 32bit counters, unused */
122122
__CTA_COUNTERS_MAX
123123
};
124124
#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)

include/linux/netfilter/nfnetlink_log.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ enum nfulnl_attr_type {
4848
NFULA_SEQ, /* instance-local sequence number */
4949
NFULA_SEQ_GLOBAL, /* global sequence number */
5050
NFULA_GID, /* group id of socket */
51+
NFULA_HWTYPE, /* hardware type */
52+
NFULA_HWHEADER, /* hardware header */
53+
NFULA_HWLEN, /* hardware header length */
5154

5255
__NFULA_MAX
5356
};

include/net/netfilter/nf_conntrack.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ struct nf_conn_help {
8888
u8 expecting[NF_CT_MAX_EXPECT_CLASSES];
8989
};
9090

91-
9291
#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
9392
#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
9493

@@ -111,11 +110,6 @@ struct nf_conn
111110
/* Timer function; drops refcnt when it goes off. */
112111
struct timer_list timeout;
113112

114-
#ifdef CONFIG_NF_CT_ACCT
115-
/* Accounting Information (same cache line as other written members) */
116-
struct ip_conntrack_counter counters[IP_CT_DIR_MAX];
117-
#endif
118-
119113
#if defined(CONFIG_NF_CONNTRACK_MARK)
120114
u_int32_t mark;
121115
#endif
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* (C) 2008 Krzysztof Piotr Oledzki <ole@ans.pl>
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+
9+
#ifndef _NF_CONNTRACK_ACCT_H
10+
#define _NF_CONNTRACK_ACCT_H
11+
#include <linux/netfilter/nf_conntrack_common.h>
12+
#include <linux/netfilter/nf_conntrack_tuple_common.h>
13+
#include <net/netfilter/nf_conntrack.h>
14+
#include <net/netfilter/nf_conntrack_extend.h>
15+
16+
struct nf_conn_counter {
17+
u_int64_t packets;
18+
u_int64_t bytes;
19+
};
20+
21+
extern int nf_ct_acct;
22+
23+
static inline
24+
struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct)
25+
{
26+
return nf_ct_ext_find(ct, NF_CT_EXT_ACCT);
27+
}
28+
29+
static inline
30+
struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
31+
{
32+
struct nf_conn_counter *acct;
33+
34+
if (!nf_ct_acct)
35+
return NULL;
36+
37+
acct = nf_ct_ext_add(ct, NF_CT_EXT_ACCT, gfp);
38+
if (!acct)
39+
pr_debug("failed to add accounting extension area");
40+
41+
42+
return acct;
43+
};
44+
45+
extern unsigned int
46+
seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir);
47+
48+
extern int nf_conntrack_acct_init(void);
49+
extern void nf_conntrack_acct_fini(void);
50+
51+
#endif /* _NF_CONNTRACK_ACCT_H */

include/net/netfilter/nf_conntrack_extend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ enum nf_ct_ext_id
77
{
88
NF_CT_EXT_HELPER,
99
NF_CT_EXT_NAT,
10+
NF_CT_EXT_ACCT,
1011
NF_CT_EXT_NUM,
1112
};
1213

1314
#define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
1415
#define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
16+
#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
1517

1618
/* Extensions: optional stuff which isn't permanently in struct. */
1719
struct nf_ct_ext {

include/net/netlink.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
896896
#define NLA_PUT_U64(skb, attrtype, value) \
897897
NLA_PUT_TYPE(skb, u64, attrtype, value)
898898

899+
#define NLA_PUT_BE64(skb, attrtype, value) \
900+
NLA_PUT_TYPE(skb, __be64, attrtype, value)
901+
899902
#define NLA_PUT_STRING(skb, attrtype, value) \
900903
NLA_PUT(skb, attrtype, strlen(value) + 1, value)
901904

net/core/dev.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@
124124
#include <linux/ip.h>
125125
#include <linux/ipv6.h>
126126
#include <linux/in.h>
127+
#include <linux/jhash.h>
128+
#include <linux/random.h>
127129

128130
#include "net-sysfs.h"
129131

@@ -1325,7 +1327,8 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
13251327

13261328
void __netif_schedule(struct Qdisc *q)
13271329
{
1328-
BUG_ON(q == &noop_qdisc);
1330+
if (WARN_ON_ONCE(q == &noop_qdisc))
1331+
return;
13291332

13301333
if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) {
13311334
struct softnet_data *sd;
@@ -1668,34 +1671,37 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
16681671
* --BLG
16691672
*/
16701673

1674+
static u32 simple_tx_hashrnd;
1675+
static int simple_tx_hashrnd_initialized = 0;
1676+
16711677
static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
16721678
{
1673-
u32 *addr, *ports, hash, ihl;
1679+
u32 addr1, addr2, ports;
1680+
u32 hash, ihl;
16741681
u8 ip_proto;
1675-
int alen;
1682+
1683+
if (unlikely(!simple_tx_hashrnd_initialized)) {
1684+
get_random_bytes(&simple_tx_hashrnd, 4);
1685+
simple_tx_hashrnd_initialized = 1;
1686+
}
16761687

16771688
switch (skb->protocol) {
16781689
case __constant_htons(ETH_P_IP):
16791690
ip_proto = ip_hdr(skb)->protocol;
1680-
addr = &ip_hdr(skb)->saddr;
1691+
addr1 = ip_hdr(skb)->saddr;
1692+
addr2 = ip_hdr(skb)->daddr;
16811693
ihl = ip_hdr(skb)->ihl;
1682-
alen = 2;
16831694
break;
16841695
case __constant_htons(ETH_P_IPV6):
16851696
ip_proto = ipv6_hdr(skb)->nexthdr;
1686-
addr = &ipv6_hdr(skb)->saddr.s6_addr32[0];
1697+
addr1 = ipv6_hdr(skb)->saddr.s6_addr32[3];
1698+
addr2 = ipv6_hdr(skb)->daddr.s6_addr32[3];
16871699
ihl = (40 >> 2);
1688-
alen = 8;
16891700
break;
16901701
default:
16911702
return 0;
16921703
}
16931704

1694-
ports = (u32 *) (skb_network_header(skb) + (ihl * 4));
1695-
1696-
hash = 0;
1697-
while (alen--)
1698-
hash ^= *addr++;
16991705

17001706
switch (ip_proto) {
17011707
case IPPROTO_TCP:
@@ -1705,14 +1711,17 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
17051711
case IPPROTO_AH:
17061712
case IPPROTO_SCTP:
17071713
case IPPROTO_UDPLITE:
1708-
hash ^= *ports;
1714+
ports = *((u32 *) (skb_network_header(skb) + (ihl * 4)));
17091715
break;
17101716

17111717
default:
1718+
ports = 0;
17121719
break;
17131720
}
17141721

1715-
return hash % dev->real_num_tx_queues;
1722+
hash = jhash_3words(addr1, addr2, ports, simple_tx_hashrnd);
1723+
1724+
return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32);
17161725
}
17171726

17181727
static struct netdev_queue *dev_pick_tx(struct net_device *dev,

net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,7 @@
1818
#include <net/netfilter/nf_conntrack_l3proto.h>
1919
#include <net/netfilter/nf_conntrack_l4proto.h>
2020
#include <net/netfilter/nf_conntrack_expect.h>
21-
22-
#ifdef CONFIG_NF_CT_ACCT
23-
static unsigned int
24-
seq_print_counters(struct seq_file *s,
25-
const struct ip_conntrack_counter *counter)
26-
{
27-
return seq_printf(s, "packets=%llu bytes=%llu ",
28-
(unsigned long long)counter->packets,
29-
(unsigned long long)counter->bytes);
30-
}
31-
#else
32-
#define seq_print_counters(x, y) 0
33-
#endif
21+
#include <net/netfilter/nf_conntrack_acct.h>
3422

3523
struct ct_iter_state {
3624
unsigned int bucket;
@@ -127,7 +115,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
127115
l3proto, l4proto))
128116
return -ENOSPC;
129117

130-
if (seq_print_counters(s, &ct->counters[IP_CT_DIR_ORIGINAL]))
118+
if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
131119
return -ENOSPC;
132120

133121
if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
@@ -138,7 +126,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
138126
l3proto, l4proto))
139127
return -ENOSPC;
140128

141-
if (seq_print_counters(s, &ct->counters[IP_CT_DIR_REPLY]))
129+
if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
142130
return -ENOSPC;
143131

144132
if (test_bit(IPS_ASSURED_BIT, &ct->status))

net/ipv4/netfilter/nf_nat_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
240240
This is only required for source (ie. NAT/masq) mappings.
241241
So far, we don't do local source mappings, so multiple
242242
manips not an issue. */
243-
if (maniptype == IP_NAT_MANIP_SRC) {
243+
if (maniptype == IP_NAT_MANIP_SRC &&
244+
!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) {
244245
if (find_appropriate_src(orig_tuple, tuple, range)) {
245246
pr_debug("get_unique_tuple: Found current src map\n");
246-
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
247-
if (!nf_nat_used_tuple(tuple, ct))
248-
return;
247+
if (!nf_nat_used_tuple(tuple, ct))
248+
return;
249249
}
250250
}
251251

0 commit comments

Comments
 (0)