Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Linus Torvalds committed Jul 21, 2008
2 parents 443bd1c + 5547cd0 commit e89970a
Show file tree
Hide file tree
Showing 30 changed files with 411 additions and 184 deletions.
10 changes: 10 additions & 0 deletions Documentation/feature-removal-schedule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,13 @@ When: After the only user (hal) has seen a release with the patches
Why: Over 1K .text/.data size reduction, data is available in other
ways (ioctls)
Who: Johannes Berg <johannes@sipsolutions.net>

---------------------------

What: CONFIG_NF_CT_ACCT
When: 2.6.29
Why: Accounting can now be enabled/disabled without kernel recompilation.
Currently used only to set a default value for a feature that is also
controlled by a kernel/module/sysfs/sysctl parameter.
Who: Krzysztof Piotr Oledzki <ole@ans.pl>

7 changes: 7 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,13 @@ and is between 256 and 4096 characters. It is defined in the file
This usage is only documented in each driver source
file if at all.

nf_conntrack.acct=
[NETFILTER] Enable connection tracking flow accounting
0 to disable accounting
1 to enable accounting
Default value depends on CONFIG_NF_CT_ACCT that is
going to be removed in 2.6.29.

nfsaddrs= [NFS]
See Documentation/filesystems/nfsroot.txt.

Expand Down
3 changes: 1 addition & 2 deletions drivers/net/atlx/atl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,6 @@ static u32 atl1_check_link(struct atl1_adapter *adapter)
dev_info(&adapter->pdev->dev, "link is down\n");
adapter->link_speed = SPEED_0;
netif_carrier_off(netdev);
netif_stop_queue(netdev);
}
return 0;
}
Expand Down Expand Up @@ -1358,7 +1357,6 @@ static u32 atl1_check_link(struct atl1_adapter *adapter)
if (!netif_carrier_ok(netdev)) {
/* Link down -> Up */
netif_carrier_on(netdev);
netif_wake_queue(netdev);
}
return 0;
}
Expand Down Expand Up @@ -2627,6 +2625,7 @@ static s32 atl1_up(struct atl1_adapter *adapter)
mod_timer(&adapter->watchdog_timer, jiffies);
atlx_irq_enable(adapter);
atl1_check_link(adapter);
netif_start_queue(netdev);
return 0;

err_up:
Expand Down
1 change: 0 additions & 1 deletion drivers/net/gianfar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,6 @@ static void adjust_link(struct net_device *dev)
if (!priv->oldlink) {
new_state = 1;
priv->oldlink = 1;
netif_tx_schedule_all(dev);
}
} else if (priv->oldlink) {
new_state = 1;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/hamradio/hdlcdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
static inline void append_crc_ccitt(unsigned char *buffer, int len)
{
unsigned int crc = crc_ccitt(0xffff, buffer, len) ^ 0xffff;
buffer += len;
*buffer++ = crc;
*buffer++ = crc >> 8;
}
Expand Down
4 changes: 0 additions & 4 deletions drivers/net/sunhme.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,8 +2377,6 @@ static void happy_meal_set_multicast(struct net_device *dev)

spin_lock_irq(&hp->happy_lock);

netif_stop_queue(dev);

if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 64)) {
hme_write32(hp, bregs + BMAC_HTABLE0, 0xffff);
hme_write32(hp, bregs + BMAC_HTABLE1, 0xffff);
Expand Down Expand Up @@ -2410,8 +2408,6 @@ static void happy_meal_set_multicast(struct net_device *dev)
hme_write32(hp, bregs + BMAC_HTABLE3, hash_table[3]);
}

netif_wake_queue(dev);

spin_unlock_irq(&hp->happy_lock);
}

Expand Down
1 change: 0 additions & 1 deletion drivers/net/ucc_geth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,6 @@ static void adjust_link(struct net_device *dev)
if (!ugeth->oldlink) {
new_state = 1;
ugeth->oldlink = 1;
netif_tx_schedule_all(dev);
}
} else if (ugeth->oldlink) {
new_state = 1;
Expand Down
8 changes: 1 addition & 7 deletions include/linux/netfilter/nf_conntrack_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ enum ip_conntrack_events
IPCT_NATINFO_BIT = 10,
IPCT_NATINFO = (1 << IPCT_NATINFO_BIT),

/* Counter highest bit has been set */
/* Counter highest bit has been set, unused */
IPCT_COUNTER_FILLING_BIT = 11,
IPCT_COUNTER_FILLING = (1 << IPCT_COUNTER_FILLING_BIT),

Expand All @@ -145,12 +145,6 @@ enum ip_conntrack_expect_events {
};

#ifdef __KERNEL__
struct ip_conntrack_counter
{
u_int32_t packets;
u_int32_t bytes;
};

struct ip_conntrack_stat
{
unsigned int searched;
Expand Down
8 changes: 4 additions & 4 deletions include/linux/netfilter/nfnetlink_conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ enum ctattr_protoinfo_sctp {

enum ctattr_counters {
CTA_COUNTERS_UNSPEC,
CTA_COUNTERS_PACKETS, /* old 64bit counters */
CTA_COUNTERS_BYTES, /* old 64bit counters */
CTA_COUNTERS32_PACKETS,
CTA_COUNTERS32_BYTES,
CTA_COUNTERS_PACKETS, /* 64bit counters */
CTA_COUNTERS_BYTES, /* 64bit counters */
CTA_COUNTERS32_PACKETS, /* old 32bit counters, unused */
CTA_COUNTERS32_BYTES, /* old 32bit counters, unused */
__CTA_COUNTERS_MAX
};
#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)
Expand Down
3 changes: 3 additions & 0 deletions include/linux/netfilter/nfnetlink_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ enum nfulnl_attr_type {
NFULA_SEQ, /* instance-local sequence number */
NFULA_SEQ_GLOBAL, /* global sequence number */
NFULA_GID, /* group id of socket */
NFULA_HWTYPE, /* hardware type */
NFULA_HWHEADER, /* hardware header */
NFULA_HWLEN, /* hardware header length */

__NFULA_MAX
};
Expand Down
6 changes: 0 additions & 6 deletions include/net/netfilter/nf_conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ struct nf_conn_help {
u8 expecting[NF_CT_MAX_EXPECT_CLASSES];
};


#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>

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

#ifdef CONFIG_NF_CT_ACCT
/* Accounting Information (same cache line as other written members) */
struct ip_conntrack_counter counters[IP_CT_DIR_MAX];
#endif

#if defined(CONFIG_NF_CONNTRACK_MARK)
u_int32_t mark;
#endif
Expand Down
51 changes: 51 additions & 0 deletions include/net/netfilter/nf_conntrack_acct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* (C) 2008 Krzysztof Piotr Oledzki <ole@ans.pl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#ifndef _NF_CONNTRACK_ACCT_H
#define _NF_CONNTRACK_ACCT_H
#include <linux/netfilter/nf_conntrack_common.h>
#include <linux/netfilter/nf_conntrack_tuple_common.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_extend.h>

struct nf_conn_counter {
u_int64_t packets;
u_int64_t bytes;
};

extern int nf_ct_acct;

static inline
struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct)
{
return nf_ct_ext_find(ct, NF_CT_EXT_ACCT);
}

static inline
struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
{
struct nf_conn_counter *acct;

if (!nf_ct_acct)
return NULL;

acct = nf_ct_ext_add(ct, NF_CT_EXT_ACCT, gfp);
if (!acct)
pr_debug("failed to add accounting extension area");


return acct;
};

extern unsigned int
seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir);

extern int nf_conntrack_acct_init(void);
extern void nf_conntrack_acct_fini(void);

#endif /* _NF_CONNTRACK_ACCT_H */
2 changes: 2 additions & 0 deletions include/net/netfilter/nf_conntrack_extend.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ enum nf_ct_ext_id
{
NF_CT_EXT_HELPER,
NF_CT_EXT_NAT,
NF_CT_EXT_ACCT,
NF_CT_EXT_NUM,
};

#define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
#define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter

/* Extensions: optional stuff which isn't permanently in struct. */
struct nf_ct_ext {
Expand Down
3 changes: 3 additions & 0 deletions include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
#define NLA_PUT_U64(skb, attrtype, value) \
NLA_PUT_TYPE(skb, u64, attrtype, value)

#define NLA_PUT_BE64(skb, attrtype, value) \
NLA_PUT_TYPE(skb, __be64, attrtype, value)

#define NLA_PUT_STRING(skb, attrtype, value) \
NLA_PUT(skb, attrtype, strlen(value) + 1, value)

Expand Down
37 changes: 23 additions & 14 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/in.h>
#include <linux/jhash.h>
#include <linux/random.h>

#include "net-sysfs.h"

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

void __netif_schedule(struct Qdisc *q)
{
BUG_ON(q == &noop_qdisc);
if (WARN_ON_ONCE(q == &noop_qdisc))
return;

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

static u32 simple_tx_hashrnd;
static int simple_tx_hashrnd_initialized = 0;

static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
{
u32 *addr, *ports, hash, ihl;
u32 addr1, addr2, ports;
u32 hash, ihl;
u8 ip_proto;
int alen;

if (unlikely(!simple_tx_hashrnd_initialized)) {
get_random_bytes(&simple_tx_hashrnd, 4);
simple_tx_hashrnd_initialized = 1;
}

switch (skb->protocol) {
case __constant_htons(ETH_P_IP):
ip_proto = ip_hdr(skb)->protocol;
addr = &ip_hdr(skb)->saddr;
addr1 = ip_hdr(skb)->saddr;
addr2 = ip_hdr(skb)->daddr;
ihl = ip_hdr(skb)->ihl;
alen = 2;
break;
case __constant_htons(ETH_P_IPV6):
ip_proto = ipv6_hdr(skb)->nexthdr;
addr = &ipv6_hdr(skb)->saddr.s6_addr32[0];
addr1 = ipv6_hdr(skb)->saddr.s6_addr32[3];
addr2 = ipv6_hdr(skb)->daddr.s6_addr32[3];
ihl = (40 >> 2);
alen = 8;
break;
default:
return 0;
}

ports = (u32 *) (skb_network_header(skb) + (ihl * 4));

hash = 0;
while (alen--)
hash ^= *addr++;

switch (ip_proto) {
case IPPROTO_TCP:
Expand All @@ -1705,14 +1711,17 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
case IPPROTO_AH:
case IPPROTO_SCTP:
case IPPROTO_UDPLITE:
hash ^= *ports;
ports = *((u32 *) (skb_network_header(skb) + (ihl * 4)));
break;

default:
ports = 0;
break;
}

return hash % dev->real_num_tx_queues;
hash = jhash_3words(addr1, addr2, ports, simple_tx_hashrnd);

return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32);
}

static struct netdev_queue *dev_pick_tx(struct net_device *dev,
Expand Down
18 changes: 3 additions & 15 deletions net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,7 @@
#include <net/netfilter/nf_conntrack_l3proto.h>
#include <net/netfilter/nf_conntrack_l4proto.h>
#include <net/netfilter/nf_conntrack_expect.h>

#ifdef CONFIG_NF_CT_ACCT
static unsigned int
seq_print_counters(struct seq_file *s,
const struct ip_conntrack_counter *counter)
{
return seq_printf(s, "packets=%llu bytes=%llu ",
(unsigned long long)counter->packets,
(unsigned long long)counter->bytes);
}
#else
#define seq_print_counters(x, y) 0
#endif
#include <net/netfilter/nf_conntrack_acct.h>

struct ct_iter_state {
unsigned int bucket;
Expand Down Expand Up @@ -127,7 +115,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
l3proto, l4proto))
return -ENOSPC;

if (seq_print_counters(s, &ct->counters[IP_CT_DIR_ORIGINAL]))
if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
return -ENOSPC;

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

if (seq_print_counters(s, &ct->counters[IP_CT_DIR_REPLY]))
if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
return -ENOSPC;

if (test_bit(IPS_ASSURED_BIT, &ct->status))
Expand Down
8 changes: 4 additions & 4 deletions net/ipv4/netfilter/nf_nat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
This is only required for source (ie. NAT/masq) mappings.
So far, we don't do local source mappings, so multiple
manips not an issue. */
if (maniptype == IP_NAT_MANIP_SRC) {
if (maniptype == IP_NAT_MANIP_SRC &&
!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) {
if (find_appropriate_src(orig_tuple, tuple, range)) {
pr_debug("get_unique_tuple: Found current src map\n");
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
if (!nf_nat_used_tuple(tuple, ct))
return;
if (!nf_nat_used_tuple(tuple, ct))
return;
}
}

Expand Down
Loading

0 comments on commit e89970a

Please sign in to comment.