Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH 2/3] korina: use netdev_alloc_skb_ip_align() here, too
From: David Miller @ 2010-06-02 13:12 UTC (permalink / raw)
  To: phil; +Cc: florian, netdev
In-Reply-To: <20100529232348.3179F4CD57@orbit.nwl.cc>

From: Phil Sutter <phil@nwl.cc>
Date: Sun, 30 May 2010 01:23:35 +0200

> This patch completes commit 89d71a66c40d629e3b1285def543ab1425558cd5
> which missed this spot, as it seems.
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>

Applied.

^ permalink raw reply

* Re: [PATCH 3/3] korina: count RX DMA OVR as rx_fifo_error
From: David Miller @ 2010-06-02 13:13 UTC (permalink / raw)
  To: phil; +Cc: florian, netdev
In-Reply-To: <20100529232345.CA3124CD45@orbit.nwl.cc>

From: Phil Sutter <phil@nwl.cc>
Date: Sun, 30 May 2010 01:23:36 +0200

> This way, RX DMA overruns (actually being caused by overrun of the
> 512byte input FIFO) show up in ifconfig output. The rx_fifo_errors
> counter is unused otherwise.
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>

Applied.

^ permalink raw reply

* Re: [PATCH v2] net/fec: fix pm to survive to suspend/resume
From: David Miller @ 2010-06-02 13:13 UTC (permalink / raw)
  To: eric; +Cc: netdev, s.hauer, sshtylyov, linux-arm-kernel, fabioestevam
In-Reply-To: <1275163490-13027-1-git-send-email-eric@eukrea.com>

From: Eric Bénard <eric@eukrea.com>
Date: Sat, 29 May 2010 22:04:50 +0200

> * in the actual driver, calling fec_stop and fec_enet_init doesn't
> allow to have a working network interface at resume (where a
> ifconfig down and up is required to recover the interface)
> * by using fec_enet_close and fec_enet_open, this patch solves this
> problem and handle the case where the link changed between suspend
> and resume
> * this patch also disable clock at suspend and reenable it at resume
> 
> Signed-off-by: Eric Bénard <eric@eukrea.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: Changli Gao @ 2010-06-02 13:14 UTC (permalink / raw)
  To: David Miller; +Cc: hadi, netdev
In-Reply-To: <20100602.054520.228955151.davem@davemloft.net>

On Wed, Jun 2, 2010 at 8:45 PM, David Miller <davem@davemloft.net> wrote:
> From: jamal <hadi@cyberus.ca>
> Date: Wed, 02 Jun 2010 08:25:38 -0400
>
>> --- a/net/sched/cls_u32.c
>> +++ b/net/sched/cls_u32.c
>> @@ -135,6 +135,9 @@ next_knode:
>>
>>  for (i = n->sel.nkeys; i>0; i--, key++) {
>>
>> +        int toff = key->off+(off2&key->offmask)- 4;
>> +        if (unlikely(toff > skb->len))
>> +              /* bailout here - needs some thought */
>>          if ((*(__be32*)(ptr+key->off+(off2&key->offmask))^key->v
>
> I don't think it's that simple.
>
> You can't dereference from the skb->data linear area if your offset is
> beyond "skb->len - skb->data_len" (aka. skb_headlen()) since that's
> where the paged or fragmented portion starts.
>
> We really need to use skb_copy_bits() if we want to allow
> any offset into the SKB, and because of all the ways
> packets can be transformed and constructed we absolutely
> have to.
>

Maybe skb_header_pointer() is lighter.


-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply

* sysfs class/net/ problem
From: Johannes Berg @ 2010-06-02 13:16 UTC (permalink / raw)
  To: netdev; +Cc: Eric W. Biederman, Greg KH

Hi,

I didn't find anything related in the archives, if I missed it I'd
appreciate a pointer. I'm currently experiencing the following:

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
# ls -l /sys/class/net/
total 0
lrwxrwxrwx 1 root root 0 Jun  2 13:12 eth0 -> ../../devices/pci0000:00/0000:00:03.0/net/eth0
lrwxrwxrwx 1 root root 0 Jun  2 13:12 lo -> ../../devices/virtual/net/lo
# insmod cfg80211.ko ; insmod mac80211.ko ; insmod mac80211_hwsim.ko  radios=3 
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
5: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 02:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
6: wlan1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 02:00:00:00:01:00 brd ff:ff:ff:ff:ff:ff
7: wlan2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 02:00:00:00:02:00 brd ff:ff:ff:ff:ff:ff
8: hwsim0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN 
    link/ieee802.11/radiotap 12:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
# ls -l /sys/class/net/
total 0
lrwxrwxrwx 1 root root 0 Jun  2 13:12 eth0 -> ../../devices/pci0000:00/0000:00:03.0/net/eth0
lrwxrwxrwx 1 root root 0 Jun  2 13:14 hwsim0 -> ../../devices/virtual/net/hwsim0
lrwxrwxrwx 1 root root 0 Jun  2 13:12 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Jun  2 13:14 wlan0 -> ../../devices/virtual/mac80211_hwsim/hwsim0/wlan0
lrwxrwxrwx 1 root root 0 Jun  2 13:14 wlan1 -> ../../devices/virtual/mac80211_hwsim/hwsim1/wlan1
lrwxrwxrwx 1 root root 0 Jun  2 13:14 wlan2 -> ../../devices/virtual/mac80211_hwsim/hwsim2/wlan2
# rmmod mac80211_hwsim mac80211 cfg80211
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
# ls -l /sys/class/net/
total 0
lrwxrwxrwx 1 root root 0 Jun  2 13:12 eth0 -> ../../devices/pci0000:00/0000:00:03.0/net/eth0
lrwxrwxrwx 1 root root 0 Jun  2 13:12 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Jun  2 13:14 wlan0 -> ../../devices/virtual/mac80211_hwsim/hwsim0/wlan0
lrwxrwxrwx 1 root root 0 Jun  2 13:14 wlan1 -> ../../devices/virtual/mac80211_hwsim/hwsim1/wlan1
lrwxrwxrwx 1 root root 0 Jun  2 13:14 wlan2 -> ../../devices/virtual/mac80211_hwsim/hwsim2/wlan2


The same problem doesn't happen with veth, so I'm not sure what's
causing the problem.

Help please?

johannes


^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: Changli Gao @ 2010-06-02 13:17 UTC (permalink / raw)
  To: hadi; +Cc: David S. Miller, netdev
In-Reply-To: <1275481219.14363.6.camel@bigi>

On Wed, Jun 2, 2010 at 8:20 PM, jamal <hadi@cyberus.ca> wrote:
>
> What i meant was if you can tell immediately what the maximum offset is
> then you dont need to go through for loop making comparison with each
> key. You could immediately bailout - which is an optimization ;->
>

I got it. But it isn't easy for me.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: David Miller @ 2010-06-02 13:27 UTC (permalink / raw)
  To: xiaosuo; +Cc: hadi, netdev
In-Reply-To: <AANLkTil0sLvcHRTcGTfYYlCYzDH07sl7xgk6EcjL99cl@mail.gmail.com>

From: Changli Gao <xiaosuo@gmail.com>
Date: Wed, 2 Jun 2010 21:14:55 +0800

> On Wed, Jun 2, 2010 at 8:45 PM, David Miller <davem@davemloft.net> wrote:
>> From: jamal <hadi@cyberus.ca>
>> Date: Wed, 02 Jun 2010 08:25:38 -0400
>>
>>> --- a/net/sched/cls_u32.c
>>> +++ b/net/sched/cls_u32.c
>>> @@ -135,6 +135,9 @@ next_knode:
>>>
>>>  for (i = n->sel.nkeys; i>0; i--, key++) {
>>>
>>> +        int toff = key->off+(off2&key->offmask)- 4;
>>> +        if (unlikely(toff > skb->len))
>>> +              /* bailout here - needs some thought */
>>>          if ((*(__be32*)(ptr+key->off+(off2&key->offmask))^key->v
>>
>> I don't think it's that simple.
>>
>> You can't dereference from the skb->data linear area if your offset is
>> beyond "skb->len - skb->data_len" (aka. skb_headlen()) since that's
>> where the paged or fragmented portion starts.
>>
>> We really need to use skb_copy_bits() if we want to allow
>> any offset into the SKB, and because of all the ways
>> packets can be transformed and constructed we absolutely
>> have to.
>>
> 
> Maybe skb_header_pointer() is lighter.

Yes, it should be.  In fact, it's designed for this kind of situation
and that's why it's used extensively in netfilter.

^ permalink raw reply

* Re: [PATCH 2/2] pktgen: receive packets and process incoming rate
From: Daniel Turull @ 2010-06-02 13:28 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, robert, jens.laas
In-Reply-To: <1275483650.2725.173.camel@edumazet-laptop>

Eric Dumazet wrote:
> Le mercredi 02 juin 2010 à 13:49 +0200, Daniel Turull a écrit :
>> This patch adds receiver part to pktgen taking advantages of SMP systems
>> with multiple rx queues:
>> - Creation of new proc file  /proc/net/pktgen/pgrx to control and display the receiver.
>> - It uses PER-CPU variable to store the results per each CPU.
>> - Results displayed per CPU and aggregated.
>> - The packet handler is add in the protocols handlers (dev_Add_pack())
>> - Available statistics: packets and bytes received, work time and rate
>> - Only process pktgen packets
>> - It is possible to select the incoming interface 
>> - Documentation updated with the new commands to control the receiver part.
>>
> 
> Interesting, but does it belongs to pktgen ?

Yes, it allows to receive a feedback of pktgen of the traffic received which comes from pktgen. It is an addition for pktgen. By default is disabled.

> other comments included :)
> 
>> Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
>>
> 
> 
>>  
>> +/*Recevier parameters per cpu*/
>> +struct pktgen_rx {
>> +	u64 rx_packets;		/*packets arrived*/
> 
> unsigned long rx_packets ?
Yes, I used the same type as the number of packets send of the transmission size
struct pktgen_dev
	__u64 sofar;


>> +	u64 rx_bytes;		/*bytes arrived*/
>> +
>> +	ktime_t start_time;	/*first time stamp of a packet*/
>> +	ktime_t last_time;	/*last packet arrival */
>> +};
> 
> 
>> +int pktgen_rcv_basic(struct sk_buff *skb, struct net_device *dev,
>> +			 struct packet_type *pt, struct net_device *orig_dev)
>> +{
>> +	/* Check magic*/
>> +	struct iphdr *iph = ip_hdr(skb);
>> +	struct pktgen_hdr *pgh;
>> +	void *vaddr;
> 
> Following code is ... well ... interesting... But ...
> 
> 1) Is it IPV6 compatable ? pktgen can be ipv6 or ipv4
It is not IPV6 compatible yet. 
> 2) Is it resistant to malicious packets ? (very small ones)
I only tried with pktgen traffic
> 3) No checksum ?
The PKTGEN_MAGIC is checked in order to validate that is a pktgen packet

> I think you should use standard mechanisms... (pskb_may_pull(), ...)
> Take a look at __netpoll_rx() for an example.

>> +	if (skb_is_nonlinear(skb)) {
>> +		vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[0]);
>> +		pgh = (struct pktgen_hdr *)
>> +			(vaddr+skb_shinfo(skb)->frags[0].page_offset);
>> +	} else {
>> +		pgh = (struct pktgen_hdr *)(((char *)(iph)) + 28);
>> +	}
>> +
>> +	if (unlikely(pgh->pgh_magic != PKTGEN_MAGIC_NET))
>> +		goto end;
>> +
>> +	if (unlikely(!__get_cpu_var(pktgen_rx_data).rx_packets))
>> +		__get_cpu_var(pktgen_rx_data).start_time = ktime_now();
>> +
>> +	__get_cpu_var(pktgen_rx_data).last_time = ktime_now();
>> +
> 
> Its a bit suboptimal to use __get_cpu_var several time. Take a look at
> disassembly code :)
> 
> Use a pointer instead

Ok, thanks for the advice. I will redo this part in order to make it compatabile with IPV6 and make it more optimal.
> 
>> +	/* Update counter of packets*/
>> +	__get_cpu_var(pktgen_rx_data).rx_packets++;
>> +	__get_cpu_var(pktgen_rx_data).rx_bytes += skb->len+14;
> 
> This +14 seems suspect (what about vlan tags ?)
> Use ETH_HLEN instead at a very minimum?

This was added, in order to add the ethernet header in the bytes in order to have the same number in tx an rx, but yes I should use ETH_HLEN

>> +end:
>> +	if (skb_is_nonlinear(skb))
>> +		kunmap_skb_frag(vaddr);
> 
> Should not recognised packets be allowed to flight in other parts of
> kernel stack ? This way, we could use ssh to remotely control this
> pktgen session ;)

This handler as a new packet type, but the packets are also delivered to the IP stack.  It is possible to control the session with ssh.

>> +	kfree_skb(skb);
>> +	return 0;
>> +}
>> +
> 


^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: jamal @ 2010-06-02 13:36 UTC (permalink / raw)
  To: Changli Gao; +Cc: David Miller, netdev
In-Reply-To: <AANLkTil0sLvcHRTcGTfYYlCYzDH07sl7xgk6EcjL99cl@mail.gmail.com>

On Wed, 2010-06-02 at 21:14 +0800, Changli Gao wrote:


> Maybe skb_header_pointer() is lighter.

A little worse than skb_copy_bits(). In any case, this change is going
to hurt.
Dave, can we assume the upper layers(qdiscs in this case) are
responsible for any linearizing?

Changli, if you have time - can you also audit tcf_pedit()
since it follows TheLinuxWay(tm).

cheers,
jamal


^ permalink raw reply

* Re: [PATCH] netfilter: Xtables: idletimer target implementation
From: Luciano Coelho @ 2010-06-02 13:37 UTC (permalink / raw)
  To: ext Jan Engelhardt
  Cc: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
	kaber@trash.net, Timo Teras
In-Reply-To: <alpine.LSU.2.01.1006021444480.14585@obet.zrqbmnf.qr>

Hi Jan,

Thanks for your prompt review! I'll send v2 with the fixes you
suggested.


On Wed, 2010-06-02 at 14:54 +0200, ext Jan Engelhardt wrote:
> On Wednesday 2010-06-02 13:58, Luciano Coelho wrote:
> >+
> >+#ifndef _XT_IDLETIMER_H
> >+#define _XT_IDLETIMER_H
> >+
> >+#define MAX_LABEL_SIZE 32
> >+
> >+struct idletimer_tg_info {
> >+	unsigned int timeout;
> >+
> >+	char label[MAX_LABEL_SIZE];
> >+};
> 
> As per "Writing Netfilter Modules" e-book, using "int" is a no-no.

Sorry I missed that one.  Fixed in v2.

 
> >+config NETFILTER_XT_TARGET_IDLETIMER
> >+	tristate  "IDLETIMER target support"
> 
> depends on NETFILTER_ADVANCED

Yes.


> >xt_IDLETIMER.c
> >+struct idletimer_tg_attr {
> >+        struct attribute attr;
> >+	ssize_t	(*show)(struct kobject *kobj,
> >+			struct attribute *attr, char *buf);
> >+};
> 
> Some indent seems to have gone wrong.

Fixed.


> >+	attr->attr.name = kstrdup(info->label, GFP_KERNEL);
> 
> Need to check return value!

Oops! Fixed in v2.  Also added sysfs_remove_file_from_group() if the
struct idletimer_tg allocation fails.


> >+	attr->attr.mode = 0444;
> 
> attr->attr.mode = S_IRUGO;

Fixed.


> 
> >+static struct xt_target idletimer_tg __read_mostly = {
> >+	.name		= "IDLETIMER",
> >+	.family		= NFPROTO_IPV4,
> 
> NFPROTO_UNSPEC

Yeps, this is a remain from the previous (and ugly) read from ipt_ip.
Fixed.


> 
> >+	.target		= idletimer_tg_target,
> >+	.targetsize     = sizeof(struct idletimer_tg_info),
> >+	.checkentry	= idletimer_tg_checkentry,
> >+	.destroy        = idletimer_tg_destroy,
> >+	.me		= THIS_MODULE,
> >+};
> >+
> >+static int __init idletimer_tg_init(void)
> >+{
> >+	int ret;
> >+
> >+	idletimer_tg_kobj = kobject_create_and_add("idletimer",
> >+						   &THIS_MODULE->mkobj.kobj);
> >+	if (!idletimer_tg_kobj)
> >+		return -ENOMEM;
> >+
> >+	/* FIXME: do we want to keep it in the module or in the net class? */
> 
> I have only ever seen interfaces in /sys/class/net, so it might be
> wise to keep it that way in light of scripts doing 
> echo /sys/class/net/*  to get a list of interfaces.

Yes, this is the only reason why I haven't put it under the net class,
which would probably look cleaner.  In other classes it seems to be
common to add misc attributes, but the net class (as of now) only
contains interface subclasses, as you said.

I'll change the FIXME to a clearer comment.


> Looks quite ok.

Thanks!


-- 
Cheers,
Luca.


^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: David Miller @ 2010-06-02 13:43 UTC (permalink / raw)
  To: hadi; +Cc: xiaosuo, netdev
In-Reply-To: <1275485797.3545.4.camel@bigi>

From: jamal <hadi@cyberus.ca>
Date: Wed, 02 Jun 2010 09:36:37 -0400

> On Wed, 2010-06-02 at 21:14 +0800, Changli Gao wrote:
> 
> 
>> Maybe skb_header_pointer() is lighter.
> 
> A little worse than skb_copy_bits(). In any case, this change is going
> to hurt.

Umm, Jamal what are you talking about?

Using skb_header_pointer(), if the offset is in range, there is no
change from today other than a comparison.

If it is not in range, we use skb_copy_bits().  It's only for the
case where we have to fetch the value from the fragmented part
of the SKB.

^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: Changli Gao @ 2010-06-02 13:43 UTC (permalink / raw)
  To: hadi; +Cc: David Miller, netdev
In-Reply-To: <1275485797.3545.4.camel@bigi>

On Wed, Jun 2, 2010 at 9:36 PM, jamal <hadi@cyberus.ca> wrote:
> On Wed, 2010-06-02 at 21:14 +0800, Changli Gao wrote:
>
>
>> Maybe skb_header_pointer() is lighter.
>
> A little worse than skb_copy_bits(). In any case, this change is going
> to hurt.

Why? it is an inline function, and in most cases, there isn't any function call.

> Dave, can we assume the upper layers(qdiscs in this case) are
> responsible for any linearizing?
>
> Changli, if you have time - can you also audit tcf_pedit()
> since it follows TheLinuxWay(tm).
>

Yea, pedit has the same issue. Besides this issue, they should use
get_unaligned() instead.


-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

^ permalink raw reply

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: jamal @ 2010-06-02 13:47 UTC (permalink / raw)
  To: David Miller; +Cc: xiaosuo, netdev
In-Reply-To: <20100602.064316.218079399.davem@davemloft.net>

On Wed, 2010-06-02 at 06:43 -0700, David Miller wrote:
> From: jamal <hadi@cyberus.ca>

> > 
> > A little worse than skb_copy_bits(). In any case, this change is going
> > to hurt.
> 
> Umm, Jamal what are you talking about?

;->

> Using skb_header_pointer(), if the offset is in range, there is no
> change from today other than a comparison.

Thats the part i glossed over - My eyes just saw "it calls
skb_copy_bits()" ;->

> If it is not in range, we use skb_copy_bits().  It's only for the
> case where we have to fetch the value from the fragmented part
> of the SKB.

cheers,
jamal


^ permalink raw reply

* [PATCH v2] netfilter: Xtables: idletimer target implementation
From: Luciano Coelho @ 2010-06-02 13:41 UTC (permalink / raw)
  To: netdev; +Cc: netfilter-devel, kaber, jengelh, Timo Teras

This patch implements an idletimer Xtables target that can be used to
identify when interfaces have been idle for a certain period of time.

Timers are identified by labels and are created when a rule is set with a new
label.  The rules also take a timeout value (in seconds) as an option.  If
more than one rule uses the same timer label, the timer will be restarted
whenever any of the rules get a hit.

One entry for each timer is created in sysfs.  This attribute contains the
timer remaining for the timer to expire.  The attributes are located under
the module's object:

/sys/module/xt_IDLETIMER/idletimer/<label>

When the timer expires, the target module sends a sysfs notification to the
userspace, which can then decide what to do (eg. disconnect to save power).

Cc: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
---
v2: Fixed according to Jan's comments

 include/linux/netfilter/xt_IDLETIMER.h |   40 ++++
 net/netfilter/Kconfig                  |   12 +
 net/netfilter/Makefile                 |    1 +
 net/netfilter/xt_IDLETIMER.c           |  360 ++++++++++++++++++++++++++++++++
 4 files changed, 413 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/netfilter/xt_IDLETIMER.h
 create mode 100644 net/netfilter/xt_IDLETIMER.c

diff --git a/include/linux/netfilter/xt_IDLETIMER.h b/include/linux/netfilter/xt_IDLETIMER.h
new file mode 100644
index 0000000..6e62224
--- /dev/null
+++ b/include/linux/netfilter/xt_IDLETIMER.h
@@ -0,0 +1,40 @@
+/*
+ * 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
+
+#define MAX_LABEL_SIZE 32
+
+struct idletimer_tg_info {
+	__u32 timeout;
+
+	char label[MAX_LABEL_SIZE];
+};
+
+#endif
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 8593a77..413ed24 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -424,6 +424,18 @@ config NETFILTER_XT_TARGET_HL
 	since you can easily create immortal packets that loop
 	forever on the network.
 
+config NETFILTER_XT_TARGET_IDLETIMER
+	tristate  "IDLETIMER target support"
+	depends on NETFILTER_ADVANCED
+	help
+
+	  This option adds the `IDLETIMER' target.  Each matching packet
+	  resets the timer associated with label specified when the rule is
+	  added.  When the timer expires, it triggers a sysfs notification.
+	  The remaining time for expiration can be read via sysfs.
+
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 config NETFILTER_XT_TARGET_LED
 	tristate '"LED" target support'
 	depends on LEDS_CLASS && LEDS_TRIGGERS
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index 14e3a8f..e28420a 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP) += xt_TCPOPTSTRIP.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_TEE) += xt_TEE.o
 obj-$(CONFIG_NETFILTER_XT_TARGET_TRACE) += xt_TRACE.o
+obj-$(CONFIG_NETFILTER_XT_TARGET_IDLETIMER) += xt_IDLETIMER.o
 
 # matches
 obj-$(CONFIG_NETFILTER_XT_MATCH_CLUSTER) += xt_cluster.o
diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
new file mode 100644
index 0000000..33fe839
--- /dev/null
+++ b/net/netfilter/xt_IDLETIMER.c
@@ -0,0 +1,360 @@
+/*
+ * linux/net/netfilter/xt_IDLETIMER.c
+ *
+ * Netfilter module to trigger a timer when packet matches.
+ * After timer expires a kevent will be sent.
+ *
+ * Copyright (C) 2004, 2010 Nokia Corporation
+ * Written by Timo Teras <ext-timo.teras@nokia.com>
+ *
+ * Converted to x_tables and reworked for upstream inclusion
+ * 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
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_IDLETIMER.h>
+#include <linux/kobject.h>
+#include <linux/workqueue.h>
+#include <linux/sysfs.h>
+
+struct idletimer_tg {
+	struct list_head entry;
+	struct timer_list timer;
+	struct work_struct work;
+
+	struct kobject *kobj;
+	struct idletimer_tg_attr *attr;
+
+	unsigned int refcnt;
+};
+
+/* Start with an empty group, we'll add attributes dynamically */
+static struct attribute *idletimer_tg_group_attrs[] = {
+	NULL,
+};
+
+static struct attribute_group idletimer_tg_group = {
+	.attrs = idletimer_tg_group_attrs,
+};
+
+struct idletimer_tg_attr {
+	struct attribute attr;
+	ssize_t	(*show)(struct kobject *kobj,
+			struct attribute *attr, char *buf);
+};
+
+static LIST_HEAD(idletimer_tg_list);
+static DEFINE_SPINLOCK(list_lock);
+
+static struct kobject *idletimer_tg_kobj;
+
+static
+struct idletimer_tg *__idletimer_tg_find_by_label(const char *label)
+{
+	struct idletimer_tg *entry;
+
+	BUG_ON(!label);
+
+	list_for_each_entry(entry, &idletimer_tg_list, entry) {
+		if (!strcmp(label, entry->attr->attr.name))
+			return entry;
+	}
+
+	return NULL;
+}
+
+static ssize_t idletimer_tg_show(struct kobject *kobj, struct attribute *attr,
+				 char *buf)
+{
+	struct idletimer_tg *timer;
+	unsigned long expires = 0;
+
+	spin_lock_bh(&list_lock);
+	timer =	__idletimer_tg_find_by_label(attr->name);
+	if (timer)
+		expires = timer->timer.expires;
+	spin_unlock_bh(&list_lock);
+
+	if (expires > jiffies)
+		return sprintf(buf, "%u\n",
+			       jiffies_to_msecs(expires - jiffies) / 1000);
+
+	return sprintf(buf, "0\n");
+}
+
+static void idletimer_tg_delete(const struct idletimer_tg_info *info)
+{
+	struct idletimer_tg *timer;
+
+	spin_lock_bh(&list_lock);
+	timer = __idletimer_tg_find_by_label(info->label);
+	if (!timer) {
+		spin_unlock_bh(&list_lock);
+		return;
+	}
+
+	if (--timer->refcnt == 0) {
+		pr_debug("deleting timer %s\n", info->label);
+
+		list_del(&timer->entry);
+		del_timer_sync(&timer->timer);
+		spin_unlock_bh(&list_lock);
+
+		sysfs_remove_file_from_group(idletimer_tg_kobj,
+					     &timer->attr->attr, NULL);
+		kfree(timer->attr->attr.name);
+		kfree(timer->attr);
+		kfree(timer);
+	} else {
+		spin_unlock_bh(&list_lock);
+		pr_debug("decreased refcnt of timer %s to %u\n",
+			 info->label, timer->refcnt);
+	}
+}
+
+static void idletimer_tg_work(struct work_struct *work)
+{
+	struct idletimer_tg *timer = container_of(work, struct idletimer_tg,
+						  work);
+
+	sysfs_notify(idletimer_tg_kobj, NULL,
+		     timer->attr->attr.name);
+}
+
+static void idletimer_tg_expired(unsigned long data)
+{
+	struct idletimer_tg *timer = (struct idletimer_tg *) data;
+
+	pr_debug("timer %s expired\n",
+		 timer->attr->attr.name);
+
+	schedule_work(&timer->work);
+}
+
+static
+struct idletimer_tg *idletimer_tg_create(const struct idletimer_tg_info *info)
+{
+	struct idletimer_tg *timer;
+	struct idletimer_tg_attr *attr;
+
+	attr = kzalloc(sizeof(attr), GFP_KERNEL);
+	if (!attr) {
+		pr_debug("couldn't alloc attribute\n");
+		return NULL;
+	}
+
+	attr->attr.name = kstrdup(info->label, GFP_KERNEL);
+	if (!attr->attr.name) {
+		pr_debug("couldn't alloc attribute name\n");
+		goto out_free_attr;
+	}
+	attr->attr.mode = S_IRUGO;
+	attr->show = idletimer_tg_show;
+
+	if (sysfs_add_file_to_group(idletimer_tg_kobj, &attr->attr, NULL)) {
+		pr_debug("couldn't add attr to sysfs\n");
+		goto out_free_name;
+	}
+
+	timer = kmalloc(sizeof(struct idletimer_tg), GFP_KERNEL);
+	if (!timer) {
+		pr_debug("couldn't alloc timer\n");
+		goto out_free_file;
+	}
+
+	spin_lock_bh(&list_lock);
+	list_add(&timer->entry, &idletimer_tg_list);
+
+	init_timer(&timer->timer);
+	setup_timer(&timer->timer, idletimer_tg_expired, (unsigned long) timer);
+	mod_timer(&timer->timer,
+		  msecs_to_jiffies(info->timeout * 1000) + jiffies);
+
+	timer->attr = attr;
+	timer->refcnt = 0;
+
+	INIT_WORK(&timer->work, idletimer_tg_work);
+	spin_unlock_bh(&list_lock);
+
+	return timer;
+
+out_free_file:
+	sysfs_remove_file_from_group(idletimer_tg_kobj,
+				     &attr->attr, NULL);
+out_free_name:
+	kfree(attr->attr.name);
+out_free_attr:
+	kfree(attr);
+	return NULL;
+}
+
+static void idletimer_tg_cleanup(void)
+{
+	struct idletimer_tg *timer;
+
+	sysfs_remove_group(idletimer_tg_kobj,
+			   &idletimer_tg_group);
+
+	spin_lock(&list_lock);
+	list_for_each_entry(timer, &idletimer_tg_list, entry) {
+		pr_debug("deleting timer %s\n", timer->attr->attr.name);
+
+		list_del(&timer->entry);
+		del_timer_sync(&timer->timer);
+		kfree(timer->attr->attr.name);
+		kfree(timer->attr);
+		kfree(timer);
+	}
+	spin_unlock(&list_lock);
+}
+
+/*
+ * The actual xt_tables plugin.
+ */
+static unsigned int idletimer_tg_target(struct sk_buff *skb,
+					 const struct xt_action_param *par)
+{
+	const struct idletimer_tg_info *info = par->targinfo;
+	struct idletimer_tg *timer;
+
+	pr_debug("resetting timer %s, timeout period %u\n",
+		 info->label, info->timeout);
+
+	spin_lock(&list_lock);
+	timer = __idletimer_tg_find_by_label(info->label);
+
+	BUG_ON(!timer);
+
+	mod_timer(&timer->timer,
+		  msecs_to_jiffies(info->timeout * 1000) + jiffies);
+	spin_unlock(&list_lock);
+
+	return XT_CONTINUE;
+}
+
+static int idletimer_tg_checkentry(const struct xt_tgchk_param *par)
+{
+	const struct idletimer_tg_info *info = par->targinfo;
+	struct idletimer_tg *timer;
+
+	pr_debug("checkentry targinfo %s\n", info->label);
+
+	if (info->timeout == 0) {
+		pr_debug("timeout value is zero\n");
+		return -EINVAL;
+	}
+
+	if (!info->label || strlen(info->label) == 0) {
+		pr_debug("label is missing\n");
+		return -EINVAL;
+	}
+
+	spin_lock(&list_lock);
+	timer = __idletimer_tg_find_by_label(info->label);
+	if (!timer) {
+		spin_unlock(&list_lock);
+		timer = idletimer_tg_create(info);
+		if (!timer) {
+			pr_debug("failed to create timer\n");
+			return -ENOMEM;
+		}
+		spin_lock(&list_lock);
+	}
+
+	timer->refcnt++;
+	mod_timer(&timer->timer,
+		  msecs_to_jiffies(info->timeout * 1000) + jiffies);
+	spin_unlock(&list_lock);
+
+	return 0;
+}
+
+static void idletimer_tg_destroy(const struct xt_tgdtor_param *par)
+{
+	const struct idletimer_tg_info *info = par->targinfo;
+
+	pr_debug("destroy targinfo %s\n", info->label);
+
+	idletimer_tg_delete(info);
+}
+
+static struct xt_target idletimer_tg __read_mostly = {
+	.name		= "IDLETIMER",
+	.family		= NFPROTO_UNSPEC,
+	.target		= idletimer_tg_target,
+	.targetsize     = sizeof(struct idletimer_tg_info),
+	.checkentry	= idletimer_tg_checkentry,
+	.destroy        = idletimer_tg_destroy,
+	.me		= THIS_MODULE,
+};
+
+static int __init idletimer_tg_init(void)
+{
+	int ret;
+
+	idletimer_tg_kobj = kobject_create_and_add("idletimer",
+						   &THIS_MODULE->mkobj.kobj);
+	if (!idletimer_tg_kobj)
+		return -ENOMEM;
+
+	/*
+	 * Maybe adding the kobj under the net class would be cleaner, but at
+	 * the moment the net class only contains interfaces as children.  So
+	 * let's keep the idletimer class inside it's own module's object to
+	 * be safe, in case someone expects all objects under net to be
+	 * actual interfaces.
+	 */
+	ret = sysfs_create_group(idletimer_tg_kobj,
+				 &idletimer_tg_group);
+	if (ret < 0) {
+		pr_debug("failed to create sysfs group");
+		return ret;
+	}
+
+	ret =  xt_register_target(&idletimer_tg);
+	if (ret < 0) {
+		kobject_put(idletimer_tg_kobj);
+		idletimer_tg_cleanup();
+		return ret;
+	}
+
+	return 0;
+}
+
+static void __exit idletimer_tg_exit(void)
+{
+	xt_unregister_target(&idletimer_tg);
+	kobject_put(idletimer_tg_kobj);
+	idletimer_tg_cleanup();
+}
+
+module_init(idletimer_tg_init);
+module_exit(idletimer_tg_exit);
+
+MODULE_AUTHOR("Timo Teras <ext-timo.teras@nokia.com>");
+MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");
+MODULE_DESCRIPTION("Xtables: idle time monitor");
+MODULE_LICENSE("GPL v2");
-- 
1.6.3.3


^ permalink raw reply related

* Re: [PATCH] cls_u32: use skb_copy_bits() to dereference data safely
From: jamal @ 2010-06-02 13:48 UTC (permalink / raw)
  To: Changli Gao; +Cc: David Miller, netdev
In-Reply-To: <AANLkTilZt3mfYt1hcDUc4VpNT5NEYoiGrFVjpGPAZH7q@mail.gmail.com>

On Wed, 2010-06-02 at 21:43 +0800, Changli Gao wrote:

> Yea, pedit has the same issue. Besides this issue, they should use
> get_unaligned() instead.

sounds reasonable - although they are probably different patches with
the offset fix being more important.

cheers,
jamal


^ permalink raw reply

* Re: [PATCH] phylib: Add support for the LXT973 phy.
From: David Miller @ 2010-06-02 13:50 UTC (permalink / raw)
  To: richardcochran; +Cc: afleming, netdev
In-Reply-To: <20100602125527.GA20396@riccoc20.at.omicron.at>

From: Richard Cochran <richardcochran@gmail.com>
Date: Wed, 2 Jun 2010 14:55:27 +0200

> On Tue, Jun 01, 2010 at 05:39:22PM -0500, Andy Fleming wrote:
>> That's a bit hacky.  There is a dev_flags field, which could be used
>> for this.  Probably, we should add a more general way of saying what
>> sort of port this is.  But don't use the presence and absence of
>> "priv", as it could one day get used for a different purpose, and this
>> seems like it would leave us open to strange bugs.
> 
> Okay, I changed it.
> 
> At first, I was worried about using 'dev_flags' because I couldn't
> tell exactly who may write to this field. Looking at tg.c and
> broadcom.c, it appears that the MAC drivers may also write this
> field. In contrast, the 'priv' field is surely private.

No, I think using dev_flags is absolutely the wrong way to do about
this.

phy_device->priv "could one day get used for a different purpose"?
What in the world are you smoking Andy?

It's clearly a private state pointer for the PHY driver to use,
full stop.  There is absolutely no ambiguity of what this value
is and what it is used for and who owns it.  The comments in the
layout of struct phy_device state this clearly as well.

On the other hand, ->dev_flags is an entirely different matter.  It's
set based upon arguments passed into PHY driver interface attach calls
and used in other various ways by the generic PHY library code.

This is entirely different from ->priv which is not touched at all
by the generic PHY code, and thus ->priv is much safer to use for
private purposes like Richard's case here.

Richard, please respin your patch so that you're using the ->priv
field like in your original patch.

Thanks.

^ permalink raw reply

* Re: [PATCH v2] act_nat: fix the wrong checksum when addr isn't in old_addr/mask
From: David Miller @ 2010-06-02 13:52 UTC (permalink / raw)
  To: herbert; +Cc: hadi, xiaosuo, netdev
In-Reply-To: <20100530125811.GA8120@gondor.apana.org.au>

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sun, 30 May 2010 22:58:11 +1000

> Yes the patch is correct.
> 
> However, the fact that you need this patch means that your act_nat
> setup isn't perfect.  Ideally all the unNATed packets should be
> filtered out before you hit act_nat.

Regardless of whether said configuration is optimal, we should
handle this case correctly.

So I have applied this patch.

^ permalink raw reply

* Re: [PATCH 00/12] sfc changes for 2.6.36
From: Ben Hutchings @ 2010-06-02 13:52 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <20100602.022144.63047920.davem@davemloft.net>

On Wed, 2010-06-02 at 02:21 -0700, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Tue, 01 Jun 2010 22:16:07 +0100
> 
> > The major feature here is RX buffer recycling, which improves
> > performance on networks with heavy multicast traffic.  Other than that,
> > there are various bug fixes and cleanup.
> > 
> > Ben.
> > 
> > Ben Hutchings (3):
> >   sfc: Rename struct efx_mcdi_phy_cfg to efx_mcdi_phy_data
> >   sfc: Only count bad packets in rx_errors
> >   sfc: Get port number from CS_PORT_NUM, not PCI function number
> > 
> > Steve Hodgson (9):
> >   sfc: Reschedule any resets scheduled inside efx_pm_freeze()
> >   sfc: Workaround flush failures on Falcon B0
> >   sfc: Synchronise link_advertising and wanted_fc on Siena
> >   sfc: Wait for the link to stay up before running loopback selftest
> >   sfc: Allow DRV_GEN events to be used outside of selftests
> >   sfc: Remove efx_rx_queue::add_lock
> >   sfc: Support only two rx buffers per page
> >   sfc: Recycle discarded rx buffers back onto the queue
> >   sfc: Allow shared pages to be recycled
> 
> ALl applied, thanks Ben.

Did you apply patch 12 "sfc: Get port number from CS_PORT_NUM, not PCI
function number" to net-2.6?

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* Re: [PATCH 00/12] sfc changes for 2.6.36
From: David Miller @ 2010-06-02 13:57 UTC (permalink / raw)
  To: bhutchings; +Cc: netdev, linux-net-drivers
In-Reply-To: <1275486746.2870.31.camel@localhost>

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Wed, 02 Jun 2010 14:52:26 +0100

> Did you apply patch 12 "sfc: Get port number from CS_PORT_NUM, not PCI
> function number" to net-2.6?

When you mix bug fixes and cleanups, I'm going to apply it all to
net-next-2.6 You didn't even specify an intended destination in your
subject lines, so you leave it entirely open for interpretation and
my choice.

So, if you want a bug fix added to net-2.6, tossing it into a series
which is not wholly appropriate for net-next-2.6 is not that way to
accomplish that.

The way to do it is:

1) Submit the bug fix, explicitly state "[PATCH net-2.6 xxx] "
   in your subject line.

2) Prepare your net-next-2.6 changes on top of that, and do one
   of two things:
   a) Explicitly state in your patch series in the "[PATCH net-next-2.6 0/xxx] "
      posting "this depends upon the bug fixes posted in the series
      XXX posted earlier.
   b) Wait for the bug fix to reach net-next-2.6 when I do a merge,
      then post your series.

Otherwise you make life way to miserable and complicated for me,
the one who has to review and integrate all of your work.

Thanks.

^ permalink raw reply

* [PATCH v2] cls_u32: use skb_header_pointer() to dereference data safely
From: Changli Gao @ 2010-06-02 14:00 UTC (permalink / raw)
  To: Jamal Hadi Salim; +Cc: David S. Miller, netdev, Changli Gao

use skb_header_pointer() to dereference data safely

the original skb->data dereference isn't safe, as there isn't any skb->len or
skb_is_nonlinear() check. skb_header_pointer() is used instead in this patch.
And when the skb isn't long enough, we terminate the function u32_classify()
immediately with -1. Unaligned access is also fixed.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 net/sched/cls_u32.c |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 13 deletions(-)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 9627542..e6dba22 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -41,6 +41,7 @@
 #include <net/netlink.h>
 #include <net/act_api.h>
 #include <net/pkt_cls.h>
+#include <asm/unaligned.h>
 
 struct tc_u_knode
 {
@@ -98,11 +99,11 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
 {
 	struct {
 		struct tc_u_knode *knode;
-		u8		  *ptr;
+		unsigned int	  off;
 	} stack[TC_U32_MAXDEPTH];
 
 	struct tc_u_hnode *ht = (struct tc_u_hnode*)tp->root;
-	u8 *ptr = skb_network_header(skb);
+	unsigned int off = skb_network_header(skb) - skb->data;
 	struct tc_u_knode *n;
 	int sdepth = 0;
 	int off2 = 0;
@@ -134,8 +135,14 @@ next_knode:
 #endif
 
 		for (i = n->sel.nkeys; i>0; i--, key++) {
-
-			if ((*(__be32*)(ptr+key->off+(off2&key->offmask))^key->val)&key->mask) {
+			unsigned int toff;
+			__be32 *data, _data;
+
+			toff = off + key->off + (off2 & key->offmask);
+			data = skb_header_pointer(skb, toff, 4, &_data);
+			if (!data)
+				goto out;
+			if ((get_unaligned(data) ^ key->val) & key->mask) {
 				n = n->next;
 				goto next_knode;
 			}
@@ -174,29 +181,46 @@ check_terminal:
 		if (sdepth >= TC_U32_MAXDEPTH)
 			goto deadloop;
 		stack[sdepth].knode = n;
-		stack[sdepth].ptr = ptr;
+		stack[sdepth].off = off;
 		sdepth++;
 
 		ht = n->ht_down;
 		sel = 0;
-		if (ht->divisor)
-			sel = ht->divisor&u32_hash_fold(*(__be32*)(ptr+n->sel.hoff), &n->sel,n->fshift);
-
+		if (ht->divisor) {
+			__be32 *data, _data;
+
+			data = skb_header_pointer(skb, off + n->sel.hoff, 4,
+						  &_data);
+			if (!data)
+				goto out;
+			sel = ht->divisor & u32_hash_fold(get_unaligned(data),
+							  &n->sel, n->fshift);
+		}
 		if (!(n->sel.flags&(TC_U32_VAROFFSET|TC_U32_OFFSET|TC_U32_EAT)))
 			goto next_ht;
 
 		if (n->sel.flags&(TC_U32_OFFSET|TC_U32_VAROFFSET)) {
 			off2 = n->sel.off + 3;
-			if (n->sel.flags&TC_U32_VAROFFSET)
-				off2 += ntohs(n->sel.offmask & *(__be16*)(ptr+n->sel.offoff)) >>n->sel.offshift;
+			if (n->sel.flags & TC_U32_VAROFFSET) {
+				__be16 *data, _data;
+
+				data = skb_header_pointer(skb,
+							  off + n->sel.offoff,
+							  2, &_data);
+				if (!data)
+					goto out;
+				off2 += ntohs(n->sel.offmask &
+					      get_unaligned(data)) >>
+					n->sel.offshift;
+			}
 			off2 &= ~3;
 		}
 		if (n->sel.flags&TC_U32_EAT) {
-			ptr += off2;
+			off += off2;
 			off2 = 0;
 		}
 
-		if (ptr < skb_tail_pointer(skb))
+		if (off < skb->len)
 			goto next_ht;
 	}
 
@@ -204,9 +228,10 @@ check_terminal:
 	if (sdepth--) {
 		n = stack[sdepth].knode;
 		ht = n->ht_up;
-		ptr = stack[sdepth].ptr;
+		off = stack[sdepth].off;
 		goto check_terminal;
 	}
+out:
 	return -1;
 
 deadloop:

^ permalink raw reply related

* Re: [PATCH] netdev:bfin_mac: reclaim and free tx skb as soon as possible after transfer
From: David Miller @ 2010-06-02 14:02 UTC (permalink / raw)
  To: sonic.adi; +Cc: netdev, uclinux-dist-devel
In-Reply-To: <1275383974.1010.5.camel@eight.analog.com>

From: sonic zhang <sonic.adi@gmail.com>
Date: Tue, 1 Jun 2010 17:19:34 +0800

> @@ -1485,6 +1506,10 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev)
>  	ndev->netdev_ops = &bfin_mac_netdev_ops;
>  	ndev->ethtool_ops = &bfin_mac_ethtool_ops;
>  
> +	init_timer(&lp->tx_reclaim_timer);
> +	lp->tx_reclaim_timer.data = (unsigned long)(lp);

Putting parenthesis around "lp" is excessive, please don't do this.

> +	lp->tx_reclaim_timer.function = (void *)tx_reclaim_skb;
> +
>  	spin_lock_init(&lp->lock);

Do not cast the function pointer to "void *" like this, it's ugly and entirely
not necessary.

Instead have a wrapper function that uses the correct types as specified
for timer functions, that calls the existing function.

^ permalink raw reply

* Re: [PATCH] ipconfig: send host-name in DHCP requests
From: David Miller @ 2010-06-02 14:05 UTC (permalink / raw)
  To: fengguang.wu; +Cc: netdev, linux-kernel, andi
In-Reply-To: <20100531031953.GA10590@localhost>

From: Wu Fengguang <fengguang.wu@intel.com>
Date: Mon, 31 May 2010 11:19:53 +0800

> Normally dhclient can be configured to send the "host-name" option
> in DHCP requests to update the client's DNS record. However for an
> NFSROOT system, dhclient shall never be called (which may change the
> IP addr and therefore lose your root NFS mount connection).
> 
> So enable updating the DNS record with kernel parameter
> 
> 	ip=::::$HOST_NAME::dhcp
> 
> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH 2/2] mac8390: raise error logging priority
From: David Miller @ 2010-06-02 14:06 UTC (permalink / raw)
  To: fthain; +Cc: geert, joe, p_gortmaker, netdev, linux-kernel, linux-m68k
In-Reply-To: <alpine.OSX.2.00.1006011739160.299@localhost>

From: Finn Thain <fthain@telegraphics.com.au>
Date: Tue, 1 Jun 2010 22:18:56 +1000 (EST)

> Log error conditions using KERN_ERR priority.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

Applied, thank you.

^ permalink raw reply

* Re: [PATCHv3] Refactor update of IPv6 flowi destination address for srcrt (RH) option
From: David Miller @ 2010-06-02 14:08 UTC (permalink / raw)
  To: arno; +Cc: joe, yoshfuji, netdev
In-Reply-To: <87sk55q44a.fsf_-_@small.ssi.corp>

From: arno@natisbad.org (Arnaud Ebalard)
Date: Wed, 02 Jun 2010 09:35:01 +0200

> Here is a v3 based on the comments I received from Joe. The helper is
> now in exthdrs.c (no more inline) and has a proper name.
> 
> Applies on net-2.6. Tested on 2.6.34.

Looks good, applied to net-next-2.6, thanks.

^ permalink raw reply

* Re: [PATCH net-next-2.6] net: replace hooks in __netif_receive_skb V5
From: David Miller @ 2010-06-02 14:11 UTC (permalink / raw)
  To: jpirko; +Cc: netdev, kaber, eric.dumazet, shemminger
In-Reply-To: <20100602075207.GD2603@psychotron.redhat.com>

From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 2 Jun 2010 09:52:08 +0200

> What this patch does is it removes two receive frame hooks (for bridge and for
> macvlan) from __netif_receive_skb. These are replaced them with a single
> hook for both. It only supports one hook per device because it makes no
> sense to do bridging and macvlan on the same device.
> 
> Then a network driver (of virtual netdev like macvlan or bridge) can register
> an rx_handler for needed net device.
> 
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Ok, this looks good to me.  Applied, thanks everyone.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox