Skip to content

Commit

Permalink
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/kaber/nf-next-2.6
  • Loading branch information
David S. Miller committed Jun 15, 2010
2 parents a3433f3 + f9181f4 commit 16fb62b
Show file tree
Hide file tree
Showing 36 changed files with 608 additions and 205 deletions.
1 change: 1 addition & 0 deletions include/linux/netfilter/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ header-y += xt_CONNMARK.h
header-y += xt_CONNSECMARK.h
header-y += xt_CT.h
header-y += xt_DSCP.h
header-y += xt_IDLETIMER.h
header-y += xt_LED.h
header-y += xt_MARK.h
header-y += xt_NFLOG.h
Expand Down
4 changes: 4 additions & 0 deletions include/linux/netfilter/nf_conntrack_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ enum ip_conntrack_status {
/* Conntrack is a template */
IPS_TEMPLATE_BIT = 11,
IPS_TEMPLATE = (1 << IPS_TEMPLATE_BIT),

/* Conntrack is a fake untracked entry */
IPS_UNTRACKED_BIT = 12,
IPS_UNTRACKED = (1 << IPS_UNTRACKED_BIT),
};

/* Connection tracking event types */
Expand Down
1 change: 1 addition & 0 deletions include/linux/netfilter/nfnetlink_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ enum nfulnl_attr_config {
#define NFULNL_COPY_NONE 0x00
#define NFULNL_COPY_META 0x01
#define NFULNL_COPY_PACKET 0x02
#define NFULNL_COPY_DISABLED 0x03

#define NFULNL_CFG_F_SEQ 0x0001
#define NFULNL_CFG_F_SEQ_GLOBAL 0x0002
Expand Down
45 changes: 45 additions & 0 deletions include/linux/netfilter/xt_IDLETIMER.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* linux/include/linux/netfilter/xt_IDLETIMER.h
*
* Header file for Xtables timer target module.
*
* Copyright (C) 2004, 2010 Nokia Corporation
* Written by Timo Teras <ext-timo.teras@nokia.com>
*
* Converted to x_tables and forward-ported to 2.6.34
* by Luciano Coelho <luciano.coelho@nokia.com>
*
* Contact: Luciano Coelho <luciano.coelho@nokia.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

#ifndef _XT_IDLETIMER_H
#define _XT_IDLETIMER_H

#include <linux/types.h>

#define MAX_IDLETIMER_LABEL_SIZE 28

struct idletimer_tg_info {
__u32 timeout;

char label[MAX_IDLETIMER_LABEL_SIZE];

/* for kernel module internal use only */
struct idletimer_tg *timer __attribute((aligned(8)));
};

#endif
11 changes: 8 additions & 3 deletions include/net/netfilter/nf_conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ extern s16 (*nf_ct_nat_offset)(const struct nf_conn *ct,
u32 seq);

/* Fake conntrack entry for untracked connections */
extern struct nf_conn nf_conntrack_untracked;
DECLARE_PER_CPU(struct nf_conn, nf_conntrack_untracked);
static inline struct nf_conn *nf_ct_untracked_get(void)
{
return &__raw_get_cpu_var(nf_conntrack_untracked);
}
extern void nf_ct_untracked_status_or(unsigned long bits);

/* Iterate over all conntracks: if iter returns true, it's deleted. */
extern void
Expand Down Expand Up @@ -285,9 +290,9 @@ static inline int nf_ct_is_dying(struct nf_conn *ct)
return test_bit(IPS_DYING_BIT, &ct->status);
}

static inline int nf_ct_is_untracked(const struct sk_buff *skb)
static inline int nf_ct_is_untracked(const struct nf_conn *ct)
{
return (skb->nfct == &nf_conntrack_untracked.ct_general);
return test_bit(IPS_UNTRACKED_BIT, &ct->status);
}

extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
Expand Down
2 changes: 1 addition & 1 deletion include/net/netfilter/nf_conntrack_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
struct nf_conn *ct = (struct nf_conn *)skb->nfct;
int ret = NF_ACCEPT;

if (ct && ct != &nf_conntrack_untracked) {
if (ct && !nf_ct_is_untracked(ct)) {
if (!nf_ct_is_confirmed(ct))
ret = __nf_conntrack_confirm(skb);
if (likely(ret == NF_ACCEPT))
Expand Down
10 changes: 7 additions & 3 deletions include/net/netfilter/xt_rateest.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
#define _XT_RATEEST_H

struct xt_rateest {
/* keep lock and bstats on same cache line to speedup xt_rateest_tg() */
struct gnet_stats_basic_packed bstats;
spinlock_t lock;
/* keep rstats and lock on same cache line to speedup xt_rateest_mt() */
struct gnet_stats_rate_est rstats;

/* following fields not accessed in hot path */
struct hlist_node list;
char name[IFNAMSIZ];
unsigned int refcnt;
spinlock_t lock;
struct gnet_estimator params;
struct gnet_stats_rate_est rstats;
struct gnet_stats_basic_packed bstats;
struct rcu_head rcu;
};

Expand Down
6 changes: 2 additions & 4 deletions net/bridge/br_netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
kfree_skb(skb);
return 0;
}
dst_hold(&rt->dst);
skb_dst_set(skb, &rt->dst);
skb_dst_set_noref(skb, &rt->dst);

skb->dev = nf_bridge->physindev;
nf_bridge_update_protocol(skb);
Expand Down Expand Up @@ -397,8 +396,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
kfree_skb(skb);
return 0;
}
dst_hold(&rt->dst);
skb_dst_set(skb, &rt->dst);
skb_dst_set_noref(skb, &rt->dst);
}

skb->dev = nf_bridge->physindev;
Expand Down
4 changes: 1 addition & 3 deletions net/ipv4/netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ static __sum16 nf_ip_checksum_partial(struct sk_buff *skb, unsigned int hook,
skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, protocol,
skb->len - dataoff, 0);
skb->ip_summed = CHECKSUM_NONE;
csum = __skb_checksum_complete_head(skb, dataoff + len);
if (!csum)
skb->ip_summed = CHECKSUM_UNNECESSARY;
return __skb_checksum_complete_head(skb, dataoff + len);
}
return csum;
}
Expand Down
7 changes: 3 additions & 4 deletions net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table)
* about).
*/
countersize = sizeof(struct xt_counters) * private->number;
counters = vmalloc_node(countersize, numa_node_id());
counters = vmalloc(countersize);

if (counters == NULL)
return ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -1005,8 +1005,7 @@ static int __do_replace(struct net *net, const char *name,
struct arpt_entry *iter;

ret = 0;
counters = vmalloc_node(num_counters * sizeof(struct xt_counters),
numa_node_id());
counters = vmalloc(num_counters * sizeof(struct xt_counters));
if (!counters) {
ret = -ENOMEM;
goto out;
Expand Down Expand Up @@ -1159,7 +1158,7 @@ static int do_add_counters(struct net *net, const void __user *user,
if (len != size + num_counters * sizeof(struct xt_counters))
return -EINVAL;

paddc = vmalloc_node(len - size, numa_node_id());
paddc = vmalloc(len - size);
if (!paddc)
return -ENOMEM;

Expand Down
57 changes: 25 additions & 32 deletions net/ipv4/netfilter/ip_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef int (*ipq_cmpfn)(struct nf_queue_entry *, unsigned long);

static unsigned char copy_mode __read_mostly = IPQ_COPY_NONE;
static unsigned int queue_maxlen __read_mostly = IPQ_QMAX_DEFAULT;
static DEFINE_RWLOCK(queue_lock);
static DEFINE_SPINLOCK(queue_lock);
static int peer_pid __read_mostly;
static unsigned int copy_range __read_mostly;
static unsigned int queue_total;
Expand Down Expand Up @@ -72,10 +72,10 @@ __ipq_set_mode(unsigned char mode, unsigned int range)
break;

case IPQ_COPY_PACKET:
copy_mode = mode;
if (range > 0xFFFF)
range = 0xFFFF;
copy_range = range;
if (copy_range > 0xFFFF)
copy_range = 0xFFFF;
copy_mode = mode;
break;

default:
Expand All @@ -101,7 +101,7 @@ ipq_find_dequeue_entry(unsigned long id)
{
struct nf_queue_entry *entry = NULL, *i;

write_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);

list_for_each_entry(i, &queue_list, list) {
if ((unsigned long)i == id) {
Expand All @@ -115,7 +115,7 @@ ipq_find_dequeue_entry(unsigned long id)
queue_total--;
}

write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
return entry;
}

Expand All @@ -136,9 +136,9 @@ __ipq_flush(ipq_cmpfn cmpfn, unsigned long data)
static void
ipq_flush(ipq_cmpfn cmpfn, unsigned long data)
{
write_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);
__ipq_flush(cmpfn, data);
write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
}

static struct sk_buff *
Expand All @@ -152,36 +152,29 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp)
struct nlmsghdr *nlh;
struct timeval tv;

read_lock_bh(&queue_lock);

switch (copy_mode) {
switch (ACCESS_ONCE(copy_mode)) {
case IPQ_COPY_META:
case IPQ_COPY_NONE:
size = NLMSG_SPACE(sizeof(*pmsg));
break;

case IPQ_COPY_PACKET:
if (entry->skb->ip_summed == CHECKSUM_PARTIAL &&
(*errp = skb_checksum_help(entry->skb))) {
read_unlock_bh(&queue_lock);
(*errp = skb_checksum_help(entry->skb)))
return NULL;
}
if (copy_range == 0 || copy_range > entry->skb->len)

data_len = ACCESS_ONCE(copy_range);
if (data_len == 0 || data_len > entry->skb->len)
data_len = entry->skb->len;
else
data_len = copy_range;

size = NLMSG_SPACE(sizeof(*pmsg) + data_len);
break;

default:
*errp = -EINVAL;
read_unlock_bh(&queue_lock);
return NULL;
}

read_unlock_bh(&queue_lock);

skb = alloc_skb(size, GFP_ATOMIC);
if (!skb)
goto nlmsg_failure;
Expand Down Expand Up @@ -242,7 +235,7 @@ ipq_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
if (nskb == NULL)
return status;

write_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);

if (!peer_pid)
goto err_out_free_nskb;
Expand All @@ -266,14 +259,14 @@ ipq_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)

__ipq_enqueue_entry(entry);

write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
return status;

err_out_free_nskb:
kfree_skb(nskb);

err_out_unlock:
write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
return status;
}

Expand Down Expand Up @@ -342,9 +335,9 @@ ipq_set_mode(unsigned char mode, unsigned int range)
{
int status;

write_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);
status = __ipq_set_mode(mode, range);
write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
return status;
}

Expand Down Expand Up @@ -440,19 +433,19 @@ __ipq_rcv_skb(struct sk_buff *skb)
if (security_netlink_recv(skb, CAP_NET_ADMIN))
RCV_SKB_FAIL(-EPERM);

write_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);

if (peer_pid) {
if (peer_pid != pid) {
write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
RCV_SKB_FAIL(-EBUSY);
}
} else {
net_enable_timestamp();
peer_pid = pid;
}

write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);

status = ipq_receive_peer(NLMSG_DATA(nlh), type,
nlmsglen - NLMSG_LENGTH(0));
Expand Down Expand Up @@ -497,10 +490,10 @@ ipq_rcv_nl_event(struct notifier_block *this,
struct netlink_notify *n = ptr;

if (event == NETLINK_URELEASE && n->protocol == NETLINK_FIREWALL) {
write_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);
if ((net_eq(n->net, &init_net)) && (n->pid == peer_pid))
__ipq_reset();
write_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
}
return NOTIFY_DONE;
}
Expand All @@ -527,7 +520,7 @@ static ctl_table ipq_table[] = {
#ifdef CONFIG_PROC_FS
static int ip_queue_show(struct seq_file *m, void *v)
{
read_lock_bh(&queue_lock);
spin_lock_bh(&queue_lock);

seq_printf(m,
"Peer PID : %d\n"
Expand All @@ -545,7 +538,7 @@ static int ip_queue_show(struct seq_file *m, void *v)
queue_dropped,
queue_user_dropped);

read_unlock_bh(&queue_lock);
spin_unlock_bh(&queue_lock);
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/netfilter/ip_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table)
(other than comefrom, which userspace doesn't care
about). */
countersize = sizeof(struct xt_counters) * private->number;
counters = vmalloc_node(countersize, numa_node_id());
counters = vmalloc(countersize);

if (counters == NULL)
return ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -1352,7 +1352,7 @@ do_add_counters(struct net *net, const void __user *user,
if (len != size + num_counters * sizeof(struct xt_counters))
return -EINVAL;

paddc = vmalloc_node(len - size, numa_node_id());
paddc = vmalloc(len - size);
if (!paddc)
return -ENOMEM;

Expand Down
Loading

0 comments on commit 16fb62b

Please sign in to comment.