Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH -mm] ath5k: remove sysctl(2) support
From: Jiri Slaby @ 2007-08-23 20:22 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: jeff, linville, netdev
In-Reply-To: <20070823083351.GA31289@localhost.sw.ru>

Alexey Dobriyan napsal(a):
> sysctl(2) is supported but frozen.

I've posted similar patch yesterday:
http://marc.info/?l=linux-mm-commits&m=118782442602108&w=2

> Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
> ---
> 
>  drivers/net/wireless/ath5k_base.c |   21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> --- a/drivers/net/wireless/ath5k_base.c
> +++ b/drivers/net/wireless/ath5k_base.c
> @@ -2438,21 +2438,12 @@ static struct pci_driver ath_pci_drv_id = {
>  	.resume		= ath_pci_resume,
>  };
>  
> -/*
> - * Static (i.e. global) sysctls.  Note that the hal sysctls
> - * are located under ours by sharing the setting for DEV_ATH.
> - */
> -enum {
> -	DEV_ATH		= 9,			/* XXX known by hal */
> -};
> -
>  static int mincalibrate = 1;
>  static int maxcalibrate = INT_MAX / 1000;
> -#define	CTL_AUTO	-2	/* cannot be CTL_ANY or CTL_NONE */
>  
>  static ctl_table ath_static_sysctls[] = {
>  #if AR_DEBUG
> -	{ .ctl_name	= CTL_AUTO,
> +	{
>  	  .procname	= "debug",
>  	  .mode		= 0644,
>  	  .data		= &ath_debug,
> @@ -2460,28 +2451,28 @@ static ctl_table ath_static_sysctls[] = {
>  	  .proc_handler	= proc_dointvec
>  	},
>  #endif
> -	{ .ctl_name	= CTL_AUTO,
> +	{
>  	  .procname	= "countrycode",
>  	  .mode		= 0444,
>  	  .data		= &countrycode,
>  	  .maxlen	= sizeof(countrycode),
>  	  .proc_handler	= proc_dointvec
>  	},
> -	{ .ctl_name	= CTL_AUTO,
> +	{
>  	  .procname	= "outdoor",
>  	  .mode		= 0444,
>  	  .data		= &outdoor,
>  	  .maxlen	= sizeof(outdoor),
>  	  .proc_handler	= proc_dointvec
>  	},
> -	{ .ctl_name	= CTL_AUTO,
> +	{
>  	  .procname	= "xchanmode",
>  	  .mode		= 0444,
>  	  .data		= &xchanmode,
>  	  .maxlen	= sizeof(xchanmode),
>  	  .proc_handler	= proc_dointvec
>  	},
> -	{ .ctl_name	= CTL_AUTO,
> +	{
>  	  .procname	= "calibrate",
>  	  .mode		= 0644,
>  	  .data		= &ath_calinterval,
> @@ -2493,7 +2484,7 @@ static ctl_table ath_static_sysctls[] = {
>  	{ 0 }
>  };
>  static ctl_table ath_ath_table[] = {
> -	{ .ctl_name	= DEV_ATH,
> +	{
>  	  .procname	= "ath",
>  	  .mode		= 0555,
>  	  .child	= ath_static_sysctls

Anyway thanks!

-- 
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University

^ permalink raw reply

* Re: [PATCH] [-MM, FIX] e1000e: incorporate napi_struct changes from net-2.6.24.git
From: David Miller @ 2007-08-23 20:14 UTC (permalink / raw)
  To: auke-jan.h.kok; +Cc: akpm, jeff, shemminger, netdev, krkumar2
In-Reply-To: <20070823145911.2467.42136.stgit@localhost.localdomain>

From: Auke Kok <auke-jan.h.kok@intel.com>
Date: Thu, 23 Aug 2007 07:59:11 -0700

> This incorporates the new napi_struct changes into e1000e. Included
> bugfix for ifdown hang from Krishna Kumar for e1000.
> 
> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply

* Re: [PATCH] improved xfrm_audit_log() patch
From: David Miller @ 2007-08-23 20:07 UTC (permalink / raw)
  To: latten; +Cc: netdev, linux-audit, sgrubb
In-Reply-To: <1187889310.15699.735.camel@faith.austin.ibm.com>

From: Joy Latten <latten@austin.ibm.com>
Date: Thu, 23 Aug 2007 12:15:10 -0500

> For example, when auditing the addition of a policy, either
> xfrm_user_audit_policy_add(xp, result, skb) or
> pfkey_audit_policy_add(xp, result) will get called. 
> I need two because xfrm_user gets loginuid/secid from netlink/skb
> and pfkey gets it from audit_get_loginuid(). 
> Each will setup and format audit buffer according
> to what they want.
> 
> Also, for deleting, there will be pfkey_audit_policy_delete(xp, result)
> and xfrm_user_audit_policy_delete(xp, result, skb).

This sounds great.

How cheap is the "auditing enabled" test?  Perhaps it can
be even inlined into the xfrm audit hooks.

^ permalink raw reply

* Re: [PATCH 2.6.23] cxgb3 - Fix dev->priv usage
From: Steve Wise @ 2007-08-23 19:25 UTC (permalink / raw)
  To: David Miller; +Cc: divy, jeff, netdev, linux-kernel
In-Reply-To: <20070813.135811.06543390.davem@davemloft.net>

This patch doesn't seem to have gone in yet????

Steve.


David Miller wrote:
> From: Divy Le Ray <divy@chelsio.com>
> Date: Mon, 13 Aug 2007 12:33:04 -0700
> 
>> From: Divy Le Ray <divy@chelsio.com>
>>
>> cxgb3 used netdev_priv() and dev->priv for different purposes.
>> In 2.6.23, netdev_priv() == dev->priv, cxgb3 needs a fix.
>> This patch is a partial backport of Dave Miller's changes in the 
>> net-2.6.24 git branch. 
>>
>> Signed-off-by: Divy Le Ray <divy@chelsio.com>
> 
> Thank you for doing this backport.
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH] fix realtek phy id in forcedeth
From: Willy Tarreau @ 2007-08-23 19:27 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Prakash Punnoor, Greg KH, stable, netdev, Ayaz Abdulla,
	linux-kernel, Chuck Ebbert
In-Reply-To: <20070823165513.GA6341@kroah.com>

Hi Greg,

On Thu, Aug 23, 2007 at 09:55:13AM -0700, Greg KH wrote:
> It might help if someone sends a real patch that can be applied :)

This is getting really silly now :-) We're all wasting more time
wondering who will send the patch than posting it. I've lost, I got
fed up first, so here it is. Please apply to mainline then stable.

Thanks,
Willy

--

>From a0e2922b99eedd9863232368ea2afe072c52783e Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Thu, 23 Aug 2007 21:35:41 +0200
Subject: [PATCH] fix realtek phy id in forcedeth

As noticed by Chuck Ebbert, commit c5e3ae8823693b260ce1f217adca8add1bc0b3de
introduced a copy-paste typo, as realtek phy is 0x732 and not 0x1c1. Obvious
fix below suggested by Ayaz Abdulla.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Cc: Ayaz Abdulla <aabdulla@nvidia.com>
Cc: Chuck Ebbert <cebbert@redhat.com>
---
 drivers/net/forcedeth.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 10f4e3b..1938d6d 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -552,7 +552,7 @@ union ring_type {
 #define PHY_OUI_MARVELL	0x5043
 #define PHY_OUI_CICADA	0x03f1
 #define PHY_OUI_VITESSE	0x01c1
-#define PHY_OUI_REALTEK	0x01c1
+#define PHY_OUI_REALTEK	0x0732
 #define PHYID1_OUI_MASK	0x03ff
 #define PHYID1_OUI_SHFT	6
 #define PHYID2_OUI_MASK	0xfc00
-- 
1.5.2.5


^ permalink raw reply related

* [PATCH v2] [02/10] pasemi_mac: Stop using the pci config space accessors for register read/writes
From: Olof Johansson @ 2007-08-23 18:13 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev, linuxppc-dev
In-Reply-To: <20070822141248.GC16830@lixom.net>

Move away from using the pci config access functions for simple register
access.  Our device has all of the registers in the config space (hey,
from the hardware point of view it looks reasonable :-), so we need to
somehow get to it. Newer firmwares have it in the device tree such that
we can just get it and ioremap it there (in case it ever moves in future
products). For now, provide a hardcoded fallback for older firmwares.


Signed-off-by: Olof Johansson <olof@lixom.net>


---

Updated: Removed explicit inlines, cleaned up read functions, fixed
grammar.


Index: mainline/drivers/net/pasemi_mac.c
===================================================================
--- mainline.orig/drivers/net/pasemi_mac.c
+++ mainline/drivers/net/pasemi_mac.c
@@ -83,44 +83,35 @@ static struct pasdma_status *dma_status;
 
 static unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int reg)
 {
-	unsigned int val;
-
-	pci_read_config_dword(mac->iob_pdev, reg, &val);
-	return val;
+	return in_le32(mac->iob_regs+reg);
 }
 
 static void write_iob_reg(struct pasemi_mac *mac, unsigned int reg,
 			  unsigned int val)
 {
-	pci_write_config_dword(mac->iob_pdev, reg, val);
+	out_le32(mac->iob_regs+reg, val);
 }
 
 static unsigned int read_mac_reg(struct pasemi_mac *mac, unsigned int reg)
 {
-	unsigned int val;
-
-	pci_read_config_dword(mac->pdev, reg, &val);
-	return val;
+	return in_le32(mac->regs+reg);
 }
 
 static void write_mac_reg(struct pasemi_mac *mac, unsigned int reg,
 			  unsigned int val)
 {
-	pci_write_config_dword(mac->pdev, reg, val);
+	out_le32(mac->regs+reg, val);
 }
 
 static unsigned int read_dma_reg(struct pasemi_mac *mac, unsigned int reg)
 {
-	unsigned int val;
-
-	pci_read_config_dword(mac->dma_pdev, reg, &val);
-	return val;
+	return in_le32(mac->dma_regs+reg);
 }
 
 static void write_dma_reg(struct pasemi_mac *mac, unsigned int reg,
 			  unsigned int val)
 {
-	pci_write_config_dword(mac->dma_pdev, reg, val);
+	out_le32(mac->dma_regs+reg, val);
 }
 
 static int pasemi_get_mac_addr(struct pasemi_mac *mac)
@@ -585,7 +576,6 @@ static int pasemi_mac_clean_tx(struct pa
 	}
 	mac->tx->next_to_clean += count;
 	spin_unlock_irqrestore(&mac->tx->lock, flags);
-
 	netif_wake_queue(mac->netdev);
 
 	return count;
@@ -1076,6 +1066,73 @@ static int pasemi_mac_poll(struct net_de
 	}
 }
 
+static void __iomem * __devinit map_onedev(struct pci_dev *p, int index)
+{
+	struct device_node *dn;
+	void __iomem *ret;
+
+	dn = pci_device_to_OF_node(p);
+	if (!dn)
+		goto fallback;
+
+	ret = of_iomap(dn, index);
+	if (!ret)
+		goto fallback;
+
+	return ret;
+fallback:
+	/* This is hardcoded and ugly, but we have some firmware versions
+	 * that don't provide the register space in the device tree. Luckily
+	 * they are at well-known locations so we can just do the math here.
+	 */
+	return ioremap(0xe0000000 + (p->devfn << 12), 0x2000);
+}
+
+static int __devinit pasemi_mac_map_regs(struct pasemi_mac *mac)
+{
+	struct resource res;
+	struct device_node *dn;
+	int err;
+
+	mac->dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
+	if (!mac->dma_pdev) {
+		dev_err(&mac->pdev->dev, "Can't find DMA Controller\n");
+		return -ENODEV;
+	}
+
+	mac->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
+	if (!mac->iob_pdev) {
+		dev_err(&mac->pdev->dev, "Can't find I/O Bridge\n");
+		return -ENODEV;
+	}
+
+	mac->regs = map_onedev(mac->pdev, 0);
+	mac->dma_regs = map_onedev(mac->dma_pdev, 0);
+	mac->iob_regs = map_onedev(mac->iob_pdev, 0);
+
+	if (!mac->regs || !mac->dma_regs || !mac->iob_regs) {
+		dev_err(&mac->pdev->dev, "Can't map registers\n");
+		return -ENODEV;
+	}
+
+	/* The dma status structure is located in the I/O bridge, and
+	 * is cache coherent.
+	 */
+	if (!dma_status) {
+		dn = pci_device_to_OF_node(mac->iob_pdev);
+		if (dn)
+			err = of_address_to_resource(dn, 1, &res);
+		if (!dn || err) {
+			/* Fallback for old firmware */
+			res.start = 0xfd800000;
+			res.end = res.start + 0x1000;
+		}
+		dma_status = __ioremap(res.start, res.end-res.start, 0);
+	}
+
+	return 0;
+}
+
 static int __devinit
 pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -1104,21 +1161,6 @@ pasemi_mac_probe(struct pci_dev *pdev, c
 
 	mac->pdev = pdev;
 	mac->netdev = dev;
-	mac->dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
-
-	if (!mac->dma_pdev) {
-		dev_err(&pdev->dev, "Can't find DMA Controller\n");
-		err = -ENODEV;
-		goto out_free_netdev;
-	}
-
-	mac->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
-
-	if (!mac->iob_pdev) {
-		dev_err(&pdev->dev, "Can't find I/O Bridge\n");
-		err = -ENODEV;
-		goto out_put_dma_pdev;
-	}
 
 	/* These should come out of the device tree eventually */
 	mac->dma_txch = index;
@@ -1161,12 +1203,9 @@ pasemi_mac_probe(struct pci_dev *pdev, c
 	dev->poll = pasemi_mac_poll;
 	dev->features = NETIF_F_HW_CSUM;
 
-	/* The dma status structure is located in the I/O bridge, and
-	 * is cache coherent.
-	 */
-	if (!dma_status)
-		/* XXXOJN This should come from the device tree */
-		dma_status = __ioremap(0xfd800000, 0x1000, 0);
+	err = pasemi_mac_map_regs(mac);
+	if (err)
+		goto out;
 
 	mac->rx_status = &dma_status->rx_sta[mac->dma_rxch];
 	mac->tx_status = &dma_status->tx_sta[mac->dma_txch];
@@ -1193,10 +1232,17 @@ pasemi_mac_probe(struct pci_dev *pdev, c
 	return err;
 
 out:
-	pci_dev_put(mac->iob_pdev);
-out_put_dma_pdev:
-	pci_dev_put(mac->dma_pdev);
-out_free_netdev:
+	if (mac->iob_pdev)
+		pci_dev_put(mac->iob_pdev);
+	if (mac->dma_pdev)
+		pci_dev_put(mac->dma_pdev);
+	if (mac->dma_regs)
+		iounmap(mac->dma_regs);
+	if (mac->iob_regs)
+		iounmap(mac->iob_regs);
+	if (mac->regs)
+		iounmap(mac->regs);
+
 	free_netdev(dev);
 out_disable_device:
 	pci_disable_device(pdev);
@@ -1220,6 +1266,10 @@ static void __devexit pasemi_mac_remove(
 	pci_dev_put(mac->dma_pdev);
 	pci_dev_put(mac->iob_pdev);
 
+	iounmap(mac->regs);
+	iounmap(mac->dma_regs);
+	iounmap(mac->iob_regs);
+
 	pci_set_drvdata(pdev, NULL);
 	free_netdev(netdev);
 }
Index: mainline/drivers/net/pasemi_mac.h
===================================================================
--- mainline.orig/drivers/net/pasemi_mac.h
+++ mainline/drivers/net/pasemi_mac.h
@@ -52,6 +52,9 @@ struct pasemi_mac_rxring {
 
 struct pasemi_mac {
 	struct net_device *netdev;
+	void __iomem *regs;
+	void __iomem *dma_regs;
+	void __iomem *iob_regs;
 	struct pci_dev *pdev;
 	struct pci_dev *dma_pdev;
 	struct pci_dev *iob_pdev;

^ permalink raw reply

* Re: [PATCH] [02/10] pasemi_mac: Stop using the pci config space accessors for register read/writes
From: Olof Johansson @ 2007-08-23 18:12 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: netdev, jgarzik, linuxppc-dev
In-Reply-To: <20070823103103.a1815a07.sfr@canb.auug.org.au>

On Thu, Aug 23, 2007 at 10:31:03AM +1000, Stephen Rothwell wrote:
> On Wed, 22 Aug 2007 09:12:48 -0500 Olof Johansson <olof@lixom.net> wrote:
> >
> > -static unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int reg)
> > +static inline unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int reg)
>           ^^^^^^
> For static functions in C files, we tend not to bother marking them
> inline any more as the compiler does a pretty good job theses days.

Yeah, sloppy coding on my behalf. It was still there from when I
explicitly added noinline during debugging, forgot to take it out
alltogether.

> > -	pci_read_config_dword(mac->iob_pdev, reg, &val);
> > +	val = in_le32(mac->iob_regs+reg);
> > +
> >  	return val;
> 
> Why not just "return in_le32(mac->iob_regs+reg);" ?
> And similarly below?

Residual from debugging as well, I had debug hooks showing what was
read/written that I took out, but didn't fix up the surrounding stuff.


Refreshed patch posted separately. Thanks for the feedback.

-Olof

^ permalink raw reply

* [PATCH] udp: randomize port selection
From: Stephen Hemminger @ 2007-08-23 18:32 UTC (permalink / raw)
  To: Rick Jones, David S. Miller; +Cc: panther, netdev
In-Reply-To: <46CDBE17.7080909@hp.com>

This patch causes UDP port allocation to be randomized like TCP.
The earlier code would always choose same port (ie first empty list).

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>


--- a/net/ipv4/udp.c	2007-08-23 09:44:22.000000000 -0700
+++ b/net/ipv4/udp.c	2007-08-23 11:29:02.000000000 -0700
@@ -113,9 +113,8 @@ DEFINE_SNMP_STAT(struct udp_mib, udp_sta
 struct hlist_head udp_hash[UDP_HTABLE_SIZE];
 DEFINE_RWLOCK(udp_hash_lock);
 
-static int udp_port_rover;
-
-static inline int __udp_lib_lport_inuse(__u16 num, struct hlist_head udptable[])
+static inline int __udp_lib_lport_inuse(__u16 num,
+					const struct hlist_head udptable[])
 {
 	struct sock *sk;
 	struct hlist_node *node;
@@ -132,11 +131,10 @@ static inline int __udp_lib_lport_inuse(
  *  @sk:          socket struct in question
  *  @snum:        port number to look up
  *  @udptable:    hash list table, must be of UDP_HTABLE_SIZE
- *  @port_rover:  pointer to record of last unallocated port
  *  @saddr_comp:  AF-dependent comparison of bound local IP addresses
  */
 int __udp_lib_get_port(struct sock *sk, unsigned short snum,
-		       struct hlist_head udptable[], int *port_rover,
+		       struct hlist_head udptable[],
 		       int (*saddr_comp)(const struct sock *sk1,
 					 const struct sock *sk2 )    )
 {
@@ -146,49 +144,56 @@ int __udp_lib_get_port(struct sock *sk, 
 	int    error = 1;
 
 	write_lock_bh(&udp_hash_lock);
-	if (snum == 0) {
-		int best_size_so_far, best, result, i;
 
-		if (*port_rover > sysctl_local_port_range[1] ||
-		    *port_rover < sysctl_local_port_range[0])
-			*port_rover = sysctl_local_port_range[0];
-		best_size_so_far = 32767;
-		best = result = *port_rover;
-		for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
-			int size;
-
-			head = &udptable[result & (UDP_HTABLE_SIZE - 1)];
-			if (hlist_empty(head)) {
-				if (result > sysctl_local_port_range[1])
-					result = sysctl_local_port_range[0] +
-						((result - sysctl_local_port_range[0]) &
-						 (UDP_HTABLE_SIZE - 1));
+	if (!snum) {
+		int i;
+		int low = sysctl_local_port_range[0];
+		int high = sysctl_local_port_range[1];
+		unsigned rover, best, best_size_so_far;
+
+		best_size_so_far = UINT_MAX;
+		best = rover = net_random() % (high - low) + low;
+
+		/* 1st pass: look for empty (or shortest) hash chain */
+		for (i = 0; i < UDP_HTABLE_SIZE; i++) {
+			int size = 0;
+
+			head = &udptable[rover & (UDP_HTABLE_SIZE - 1)];
+			if (hlist_empty(head))
 				goto gotit;
-			}
-			size = 0;
+
 			sk_for_each(sk2, node, head) {
 				if (++size >= best_size_so_far)
 					goto next;
 			}
 			best_size_so_far = size;
-			best = result;
+			best = rover;
 		next:
-			;
+			/* fold back if end of range */
+			if (++rover > high)
+				rover = low + ((rover - low)
+					       & (UDP_HTABLE_SIZE - 1));
+
+
 		}
-		result = best;
-		for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE;
-		     i++, result += UDP_HTABLE_SIZE) {
-			if (result > sysctl_local_port_range[1])
-				result = sysctl_local_port_range[0]
-					+ ((result - sysctl_local_port_range[0]) &
-					   (UDP_HTABLE_SIZE - 1));
-			if (! __udp_lib_lport_inuse(result, udptable))
-				break;
+
+		/* 2nd pass: find hole in shortest hash chain */
+		rover = best;
+		for (i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++) {
+			if (! __udp_lib_lport_inuse(rover, udptable))
+				goto gotit;
+			rover += UDP_HTABLE_SIZE;
+			if (rover > high)
+				rover = low + ((rover - low)
+					       & (UDP_HTABLE_SIZE - 1));
 		}
-		if (i >= (1 << 16) / UDP_HTABLE_SIZE)
-			goto fail;
+
+
+		/* All ports in use! */
+		goto fail;
+
 gotit:
-		*port_rover = snum = result;
+		snum = rover;
 	} else {
 		head = &udptable[snum & (UDP_HTABLE_SIZE - 1)];
 
@@ -201,6 +206,7 @@ gotit:
 			    (*saddr_comp)(sk, sk2)                             )
 				goto fail;
 	}
+
 	inet_sk(sk)->num = snum;
 	sk->sk_hash = snum;
 	if (sk_unhashed(sk)) {
@@ -217,7 +223,7 @@ fail:
 int udp_get_port(struct sock *sk, unsigned short snum,
 			int (*scmp)(const struct sock *, const struct sock *))
 {
-	return  __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp);
+	return  __udp_lib_get_port(sk, snum, udp_hash, scmp);
 }
 
 int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
--- a/net/ipv4/udp_impl.h	2007-08-23 09:44:22.000000000 -0700
+++ b/net/ipv4/udp_impl.h	2007-08-23 11:26:48.000000000 -0700
@@ -9,7 +9,7 @@ extern int  	__udp4_lib_rcv(struct sk_bu
 extern void 	__udp4_lib_err(struct sk_buff *, u32, struct hlist_head []);
 
 extern int	__udp_lib_get_port(struct sock *sk, unsigned short snum,
-				   struct hlist_head udptable[], int *port_rover,
+				   struct hlist_head udptable[],
 				   int (*)(const struct sock*,const struct sock*));
 extern int	ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
 
--- a/net/ipv4/udplite.c	2007-08-23 09:44:22.000000000 -0700
+++ b/net/ipv4/udplite.c	2007-08-23 11:25:33.000000000 -0700
@@ -16,12 +16,11 @@
 DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics)	__read_mostly;
 
 struct hlist_head 	udplite_hash[UDP_HTABLE_SIZE];
-static int		udplite_port_rover;
 
 int udplite_get_port(struct sock *sk, unsigned short p,
 		     int (*c)(const struct sock *, const struct sock *))
 {
-	return  __udp_lib_get_port(sk, p, udplite_hash, &udplite_port_rover, c);
+	return  __udp_lib_get_port(sk, p, udplite_hash, c);
 }
 
 static int udplite_v4_get_port(struct sock *sk, unsigned short snum)

^ permalink raw reply

* Re: [IPv6] Add v4mapped address inline
From: Brian Haley @ 2007-08-23 18:14 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki / ????; +Cc: davem, netdev, lksctp-developers
In-Reply-To: <20070824.030002.56135604.yoshfuji@linux-ipv6.org>

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

YOSHIFUJI Hideaki / ???? wrote:
> Please put this just after ipv6_addr_any(), not after
> ipv6_addr_diff().

Ok, updated patch attached.

-Brian


Add v4mapped address inline to avoid calls to ipv6_addr_type().

Signed-off-by: Brian Haley <brian.haley@hp.com>

[-- Attachment #2: v4mapped.inline.patch --]
[-- Type: text/x-patch, Size: 3337 bytes --]

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 9059e0e..37bdb25 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -377,6 +377,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
 		 a->s6_addr32[2] | a->s6_addr32[3] ) == 0); 
 }
 
+static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+	return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 && 
+		 a->s6_addr32[2] == htonl(0x0000ffff)); 
+}
+
 /*
  * find the first different bit between two addresses
  * length of address must be a multiple of 32bits
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 761a910..92d8119 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -249,7 +249,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 			}
 
 			if (ipv6_only_sock(sk) ||
-			    !(ipv6_addr_type(&np->daddr) & IPV6_ADDR_MAPPED)) {
+			    !ipv6_addr_v4mapped(&np->daddr)) {
 				retv = -EADDRNOTAVAIL;
 				break;
 			}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0f7defb..d5c0175 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -697,7 +697,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
 	if (!cmd.tcpm_keylen) {
 		if (!tcp_sk(sk)->md5sig_info)
 			return -ENOENT;
-		if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
+		if (ipv6_addr_v4mapped(&sin6->sin6_addr))
 			return tcp_v4_md5_do_del(sk, sin6->sin6_addr.s6_addr32[3]);
 		return tcp_v6_md5_do_del(sk, &sin6->sin6_addr);
 	}
@@ -720,7 +720,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
 	newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
 	if (!newkey)
 		return -ENOMEM;
-	if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED) {
+	if (ipv6_addr_v4mapped(&sin6->sin6_addr)) {
 		return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3],
 					 newkey, cmd.tcpm_keylen);
 	}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4210951..3e0ca15 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -610,7 +610,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
 		daddr = NULL;
 
 	if (daddr) {
-		if (ipv6_addr_type(daddr) == IPV6_ADDR_MAPPED) {
+		if (ipv6_addr_v4mapped(daddr)) {
 			struct sockaddr_in sin;
 			sin.sin_family = AF_INET;
 			sin.sin_port = sin6 ? sin6->sin6_port : inet->dport;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index f8aa23d..cd57a51 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -481,7 +481,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
 	if (addr1->sa.sa_family != addr2->sa.sa_family) {
 		if (addr1->sa.sa_family == AF_INET &&
 		    addr2->sa.sa_family == AF_INET6 &&
-		    IPV6_ADDR_MAPPED == ipv6_addr_type(&addr2->v6.sin6_addr)) {
+		    ipv6_addr_v4mapped(&addr2->v6.sin6_addr)) {
 			if (addr2->v6.sin6_port == addr1->v4.sin_port &&
 			    addr2->v6.sin6_addr.s6_addr32[3] ==
 			    addr1->v4.sin_addr.s_addr)
@@ -489,7 +489,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
 		}
 		if (addr2->sa.sa_family == AF_INET &&
 		    addr1->sa.sa_family == AF_INET6 &&
-		    IPV6_ADDR_MAPPED == ipv6_addr_type(&addr1->v6.sin6_addr)) {
+		    ipv6_addr_v4mapped(&addr1->v6.sin6_addr)) {
 			if (addr1->v6.sin6_port == addr2->v4.sin_port &&
 			    addr1->v6.sin6_addr.s6_addr32[3] ==
 			    addr2->v4.sin_addr.s_addr)

^ permalink raw reply related

* Re: [stable] [2.6.20.17 review 35/58] forcedeth bug fix: realtek phy
From: Greg KH @ 2007-08-23 16:55 UTC (permalink / raw)
  To: Prakash Punnoor
  Cc: Greg KH, stable, netdev, Willy Tarreau, Ayaz Abdulla,
	linux-kernel
In-Reply-To: <200708231750.45257.prakash@punnoor.de>

On Thu, Aug 23, 2007 at 05:50:41PM +0200, Prakash Punnoor wrote:
> On the day of Thursday 23 August 2007 Greg KH hast written:
> > On Wed, Aug 22, 2007 at 10:42:25PM +0200, Willy Tarreau wrote:
> > > On Wed, Aug 22, 2007 at 08:15:03PM +0200, Prakash Punnoor wrote:
> > > > Hi,
> > > >
> > > > even if Greg is waiting for some special invitation
> > > > (http://lkml.org/lkml/2007/8/14/229), I suggest putting this patch by
> > > > Ayaz on top:
> > > >
> > > > http://lkml.org/lkml/2007/8/10/296
> > >
> > > That's what I prepare first, but then noticed it's not in mainline.
> > >
> > > > Perhaps Ayaz wants to give Greg the clarification he needs... :sigh:
> > >
> > > He should, as the fix is not in mainline either :-(
> > > I don't think Greg asks for specific clarification, just a plain patch
> > > with a short commit log on its own which does not include remains of
> > > older mails.
> >
> > Exactly, that is what I am waiting for.
> >
> > And also I need the change to go into mainline first, as we can not
> > diverge with the -stable releases.
> 
> Can we get that into mainline then? I haven't seen forcedeth in MAINTAINERS, 
> so I added netdev to the cc list.

It might help if someone sends a real patch that can be applied :)

thanks,

greg k-h

^ permalink raw reply

* Re: [IPv6] Add v4mapped address inline
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-08-23 18:00 UTC (permalink / raw)
  To: brian.haley; +Cc: davem, netdev, lksctp-developers, yoshfuji
In-Reply-To: <46CDB896.8040408@hp.com>

Hello.

In article <46CDB896.8040408@hp.com> (at Thu, 23 Aug 2007 12:40:54 -0400), Brian Haley <brian.haley@hp.com> says:

> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index 9059e0e..c2b6c11 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -418,6 +418,12 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
>  	return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
>  }
>  
> +static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
> +{
> +	return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 && 
> +		 a->s6_addr32[2] == htonl(0x0000ffff)); 
> +}
> +

Please put this just after ipv6_addr_any(), not after
ipv6_addr_diff().

--yoshfuji

^ permalink raw reply

* Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG
From: John W. Linville @ 2007-08-23 17:08 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Joe Perches, David S. Miller, netdev
In-Reply-To: <1187885520.22725.4.camel@johannes.berg>

On Thu, Aug 23, 2007 at 06:12:00PM +0200, Johannes Berg wrote:
> On Thu, 2007-08-23 at 09:01 -0700, Joe Perches wrote:
> > There are also several different uses of the equivalent of
> > 
> > 	printk("%02x",addr[0])
> > 	for (i=1; i<6; i++)
> > 		printk(":%02x",addr[i]);
> > 
> > to print an ethernet MAC address.
> 
> Hm. I didn't know that, I can go through in a later patch if desired.
> 
> > http://www.uwsg.iu.edu/hypermail/linux/net/0602.1/0002.html
> > 
> > As not all device MAC addresses are 6 bytes, colon separated,
> > perhaps an appropriate ethernet/tr MAC designation is EUI48.
> > 
> > http://standards.ieee.org/regauth/oui/tutorials/EUI48.html
> 
> Practically, however, nobody is going to even find macros named
> EUI48_FMT/EUI48_ARG, would they? I don't much care, but I find it rather
> unsatisfying that both wireless code bases define these macros.

Yeah, accomodating non-48-bit MAC addresses is a bit pedantic.

I ACK the original patch, FWIW.

John
-- 
John W. Linville
linville@tuxdriver.com

^ permalink raw reply

* Re: [PATCH] improved xfrm_audit_log() patch
From: Joy Latten @ 2007-08-23 17:15 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-audit, sgrubb
In-Reply-To: <20070822.200502.35874480.davem@davemloft.net>

On Wed, 2007-08-22 at 20:05 -0700, David Miller wrote:
> I would suggest, at this point, to make purpose built situation
> specific interfaces that pass specific objects (the ones being
> operated upon) to the audit layer.
> 
> Let the audit layer pick out the bits it actually wants in the
> format it likes.
> 
> For example, if we're creating a template, pass the policy and
> the templace to the audit layer via a function called:
> 
> xfrm_audit_template_add()
> 
> or something like that.  That function only needs two arguments.
> 
> All of these call sites will rarely need more than 2 or 3 arguments in
> any given situation, and the on-stack audit thing will be gone too.
> 
> This is the suggestion I made to you over a month ago, but you choose
> to do the on-stack thing.
> 
I misunderstood. My bad.

For clarification, I plan on removing xfrm_audit_log() and replacing it
with more specific ipsec audit interfaces. 

For example, when auditing the addition of a policy, either
xfrm_user_audit_policy_add(xp, result, skb) or
pfkey_audit_policy_add(xp, result) will get called. 
I need two because xfrm_user gets loginuid/secid from netlink/skb
and pfkey gets it from audit_get_loginuid(). 
Each will setup and format audit buffer according
to what they want.

Also, for deleting, there will be pfkey_audit_policy_delete(xp, result)
and xfrm_user_audit_policy_delete(xp, result, skb).

> You must make this cost absolutely nothing when it is either
> not configured, and have next to no cost when not enabled at
> run time.  And it is very doable.

The new ipsec audit functions can be ifdef'd with CONFIG_AUDITSYSCALL
just as xfrm_audit_log() was so that there is no cost when 
audit is not configured. 

Let me know if this is better.

Regards,
Joy

^ permalink raw reply

* Re: UDPv4 port allocation problem
From: Rick Jones @ 2007-08-23 17:04 UTC (permalink / raw)
  To: panther; +Cc: netdev
In-Reply-To: <46CD3462.2070403@balabit.hu>

Tóth László Attila wrote:
> Hello,
> 
> I noticed that it is possible that the kernel allocates the same UDP

_Which_ kernel - or rather which rev?  There are lots of linux kernels 
potentially out there...

> port to an application that was used and closed immediately before the
> new application got it. This means that applications that do not specify
> an exact port and rely on the  kernel to allocate a port for them might
> see traffic originally meant for another application.
> 
> Imagine that two applications want to resolve a name in DNS at about the
> same time. The following happens:
>  * first app sends out the DNS query then closes the socket without
> waiting for an answer (e.g. it got interrupted by Ctrl+C)
>  * second app opens an UDP socket, and gets the same port, originally
> assigned to app#1, sends out the DNS query
>  * DNS server responds, the response goes to app#2
> 
> DNS might not be the perfect example, but you get the idea. 
> Applications do not expect to receive data on newly opened sockets, not
> to mention the security implications.

Actually, all applications using UDP are required to cope with just about 
anything since there are no guarantees with UDP of anything other than the 
checksum generally protecting one from corrupt data.

In the specific case of DNS, the resolver library will (damn well better) be 
checking the answer it gets against the query it sent.  There will be a 
transaction ID check, and IIRC a check of the returned query against the query sent.

> TCP on the other hand increases the allocated port number for each new
> socket, the same behaviour for UDP would add certain amount of time that
> decreases this risk.

Does it always?  If you wait for the length of TIME_WAIT before issuing another 
bind() request does the port number still increase?


While it might be nice to step through the anonymous port space in some fashion 
(I suspect the argument would be made that it should be somewhat random to 
preclude guessing from the outside), applications using UDP are still required 
to expect the unexpected wrt data arriving on their socket.

rick jones

> 
> Is the current behaviour intended?
> 
> Regards,
> Laszlo Attila Toth
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply

* [PATCH] shaper: mark for removal
From: Stephen Hemminger @ 2007-08-23 16:44 UTC (permalink / raw)
  To: David Miller; +Cc: alan, netdev, Adrian Bunk
In-Reply-To: <20070822.170133.05603862.davem@davemloft.net>

Subject: shaper: mark for removal

This driver has been marked obsolete for a long time and
is superseded by traffic schedulers.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>


--- a/Documentation/feature-removal-schedule.txt	2007-08-23 09:36:24.000000000 -0700
+++ b/Documentation/feature-removal-schedule.txt	2007-08-23 09:43:24.000000000 -0700
@@ -290,3 +290,12 @@ Why:	All mthca hardware also supports MS
 Who:	Roland Dreier <rolandd@cisco.com>
 
 ---------------------------
+
+What:	shaper network driver
+When:	January 2008
+Files:	drivers/net/shaper.c, include/linux/if_shaper.h
+Why:	This driver has been marked obsolete for many years.
+	It was only designed to work on lower speed links and has design
+	flaws that lead to machine crashes. The qdisc infrastructure in
+	2.4 or later kernels, provides richer features and is more robust.
+Who:	Stephen Hemminger <shemminger@linux-foundation.org>

^ permalink raw reply

* [IPv6] Add v4mapped address inline
From: Brian Haley @ 2007-08-23 16:40 UTC (permalink / raw)
  To: David Miller, YOSHIFUJI Hideaki; +Cc: netdev@vger.kernel.org, lksctp-developers

[-- Attachment #1: Type: text/plain, Size: 64 bytes --]

Add v4mapped address inline to avoid calls to ipv6_addr_type().

[-- Attachment #2: v4mapped.inline.patch --]
[-- Type: text/x-patch, Size: 3303 bytes --]

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 9059e0e..c2b6c11 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -418,6 +418,12 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
 	return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
 }
 
+static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+	return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 && 
+		 a->s6_addr32[2] == htonl(0x0000ffff)); 
+}
+
 /*
  *	Prototypes exported by ipv6
  */
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 761a910..92d8119 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -249,7 +249,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 			}
 
 			if (ipv6_only_sock(sk) ||
-			    !(ipv6_addr_type(&np->daddr) & IPV6_ADDR_MAPPED)) {
+			    !ipv6_addr_v4mapped(&np->daddr)) {
 				retv = -EADDRNOTAVAIL;
 				break;
 			}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0f7defb..d5c0175 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -697,7 +697,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
 	if (!cmd.tcpm_keylen) {
 		if (!tcp_sk(sk)->md5sig_info)
 			return -ENOENT;
-		if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
+		if (ipv6_addr_v4mapped(&sin6->sin6_addr))
 			return tcp_v4_md5_do_del(sk, sin6->sin6_addr.s6_addr32[3]);
 		return tcp_v6_md5_do_del(sk, &sin6->sin6_addr);
 	}
@@ -720,7 +720,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
 	newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
 	if (!newkey)
 		return -ENOMEM;
-	if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED) {
+	if (ipv6_addr_v4mapped(&sin6->sin6_addr)) {
 		return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3],
 					 newkey, cmd.tcpm_keylen);
 	}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4210951..3e0ca15 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -610,7 +610,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
 		daddr = NULL;
 
 	if (daddr) {
-		if (ipv6_addr_type(daddr) == IPV6_ADDR_MAPPED) {
+		if (ipv6_addr_v4mapped(daddr)) {
 			struct sockaddr_in sin;
 			sin.sin_family = AF_INET;
 			sin.sin_port = sin6 ? sin6->sin6_port : inet->dport;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index f8aa23d..cd57a51 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -481,7 +481,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
 	if (addr1->sa.sa_family != addr2->sa.sa_family) {
 		if (addr1->sa.sa_family == AF_INET &&
 		    addr2->sa.sa_family == AF_INET6 &&
-		    IPV6_ADDR_MAPPED == ipv6_addr_type(&addr2->v6.sin6_addr)) {
+		    ipv6_addr_v4mapped(&addr2->v6.sin6_addr)) {
 			if (addr2->v6.sin6_port == addr1->v4.sin_port &&
 			    addr2->v6.sin6_addr.s6_addr32[3] ==
 			    addr1->v4.sin_addr.s_addr)
@@ -489,7 +489,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
 		}
 		if (addr2->sa.sa_family == AF_INET &&
 		    addr1->sa.sa_family == AF_INET6 &&
-		    IPV6_ADDR_MAPPED == ipv6_addr_type(&addr1->v6.sin6_addr)) {
+		    ipv6_addr_v4mapped(&addr1->v6.sin6_addr)) {
 			if (addr1->v6.sin6_port == addr2->v4.sin_port &&
 			    addr1->v6.sin6_addr.s6_addr32[3] ==
 			    addr2->v4.sin_addr.s_addr)

^ permalink raw reply related

* New NAPI interface: netif_rx_reschedule not working
From: Jan-Bernd Themann @ 2007-08-23 16:21 UTC (permalink / raw)
  To: David.Miller; +Cc: netdev, Christoph Raisch, Thomas Klein

Hi David,

when trying to get our driver working with the new interface, 
I found the following issue where I'm not sure how to solve it best:

netif_rx_reschedule() does not work when called after netif_rx_complete().
The problem is that netif_rx_reschedule currently adds the napi struct once 
more to the poll list. However, net_rx_action will add it to the poll list
as well (NAPI_STATE_SCHED set), so the device is scheduled twice. 
Next time netif_rx_complete is called for the second schedule, 
it will result in BUG() because NAPI_STATE_SCHED
is not set anymore (cleared by first netif_rx_complete()).

Modifying netif_rx_reschedule to only set NAPI_STATE_SCHED flag again
and not adding the device to the poll_list will not solve the problem entirely.

After netif_rx_complete() the driver activates the IRQs again. If
an IRQ is caught on a different CPU before netif_rx_reschedule is called,
we will have the napi device scheduled twice again... because
net_rx_action will schedule it and netif_rx_schedule as well
(add it to poll_list).

I think this is an issue that can even occur if you don't use
netif_rx_reschedule. Do I understand this correctly?

Thanks,
Jan-Bernd


^ permalink raw reply

* Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG
From: Johannes Berg @ 2007-08-23 16:12 UTC (permalink / raw)
  To: Joe Perches; +Cc: David S. Miller, netdev
In-Reply-To: <1187884912.32738.24.camel@localhost>

[-- Attachment #1: Type: text/plain, Size: 798 bytes --]

On Thu, 2007-08-23 at 09:01 -0700, Joe Perches wrote:
> There are also several different uses of the equivalent of
> 
> 	printk("%02x",addr[0])
> 	for (i=1; i<6; i++)
> 		printk(":%02x",addr[i]);
> 
> to print an ethernet MAC address.

Hm. I didn't know that, I can go through in a later patch if desired.

> http://www.uwsg.iu.edu/hypermail/linux/net/0602.1/0002.html
> 
> As not all device MAC addresses are 6 bytes, colon separated,
> perhaps an appropriate ethernet/tr MAC designation is EUI48.
> 
> http://standards.ieee.org/regauth/oui/tutorials/EUI48.html

Practically, however, nobody is going to even find macros named
EUI48_FMT/EUI48_ARG, would they? I don't much care, but I find it rather
unsatisfying that both wireless code bases define these macros.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply

* Re: [PATCH 1/2] E1000: Fix ifdown hang in git-2.6.24
From: Kok, Auke @ 2007-08-23 16:11 UTC (permalink / raw)
  To: davem; +Cc: Krishna Kumar, netdev
In-Reply-To: <20070823090418.13099.89298.sendpatchset@localhost.localdomain>

Krishna Kumar wrote:
> Doing napi_disable twice hangs "ifdown" of the device. e1000_down is the
> common place to call napi_disable.
> 
> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
> ---
>  e1000_main.c |    4 ----
>  1 files changed, 4 deletions(-)
> 
> diff -ruNp org/drivers/net/e1000/e1000_main.c new/drivers/net/e1000/e1000_main.c
> --- org/drivers/net/e1000/e1000_main.c	2007-08-23 13:32:16.000000000 +0530
> +++ new/drivers/net/e1000/e1000_main.c	2007-08-23 13:32:34.000000000 +0530
> @@ -1477,10 +1477,6 @@ e1000_close(struct net_device *netdev)
>  {
>  	struct e1000_adapter *adapter = netdev_priv(netdev);
>  
> -#ifdef CONFIG_E1000_NAPI
> -	napi_disable(&adapter->napi);
> -#endif
> -
>  	WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
>  	e1000_down(adapter);
>  	e1000_power_down_phy(adapter);

Acked-by: Auke Kok <auke-jan.h.kok@intel.com>

I pushed this change to akpm for -mm as well in e1000e...

Thanks Krishna,

Auke

^ permalink raw reply

* Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG
From: Joe Perches @ 2007-08-23 16:01 UTC (permalink / raw)
  To: Johannes Berg; +Cc: David S. Miller, netdev
In-Reply-To: <1187808408.4314.15.camel@johannes.berg>

On Wed, 2007-08-22 at 20:46 +0200, Johannes Berg wrote:
> The two different wireless code bases both define macros to ease
> printing MAC addresses:

There are also several different uses of the equivalent of

	printk("%02x",addr[0])
	for (i=1; i<6; i++)
		printk(":%02x",addr[i]);

to print an ethernet MAC address.

http://www.uwsg.iu.edu/hypermail/linux/net/0602.1/0002.html

As not all device MAC addresses are 6 bytes, colon separated,
perhaps an appropriate ethernet/tr MAC designation is EUI48.

http://standards.ieee.org/regauth/oui/tutorials/EUI48.html


^ permalink raw reply

* Re: [2.6.20.17 review 35/58] forcedeth bug fix: realtek phy
From: Prakash Punnoor @ 2007-08-23 15:50 UTC (permalink / raw)
  To: Greg KH; +Cc: Willy Tarreau, linux-kernel, stable, Ayaz Abdulla, netdev
In-Reply-To: <20070822230526.GC32121@suse.de>

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

On the day of Thursday 23 August 2007 Greg KH hast written:
> On Wed, Aug 22, 2007 at 10:42:25PM +0200, Willy Tarreau wrote:
> > On Wed, Aug 22, 2007 at 08:15:03PM +0200, Prakash Punnoor wrote:
> > > Hi,
> > >
> > > even if Greg is waiting for some special invitation
> > > (http://lkml.org/lkml/2007/8/14/229), I suggest putting this patch by
> > > Ayaz on top:
> > >
> > > http://lkml.org/lkml/2007/8/10/296
> >
> > That's what I prepare first, but then noticed it's not in mainline.
> >
> > > Perhaps Ayaz wants to give Greg the clarification he needs... :sigh:
> >
> > He should, as the fix is not in mainline either :-(
> > I don't think Greg asks for specific clarification, just a plain patch
> > with a short commit log on its own which does not include remains of
> > older mails.
>
> Exactly, that is what I am waiting for.
>
> And also I need the change to go into mainline first, as we can not
> diverge with the -stable releases.

Can we get that into mainline then? I haven't seen forcedeth in MAINTAINERS, 
so I added netdev to the cc list.

bye,
-- 
(°=                 =°)
//\ Prakash Punnoor /\\
V_/                 \_V

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses
From: Chuck Lever @ 2007-08-23 15:39 UTC (permalink / raw)
  To: Aurélien Charbon; +Cc: Mailing list NFSv4, netdev ML
In-Reply-To: <46CD890C.2040502@ext.bull.net>

[-- Attachment #1: Type: text/plain, Size: 3989 bytes --]

Hi Aurélien-

Aurélien Charbon wrote:
> According to Neil's comments, I have tried to correct the mistakes of my first sending
> Thank you for these comments Neil.
> 
> This is a small part of missing pieces of IPv6 support for the server.
> It deals with the ip_map caching code part.
> 
> It changes the ip_map structure to be able to store INET6 addresses.
> It adds also the changes in address hashing, and mapping to test it with INET addresses.
> 
> Signed-off-by: Aurelien Charbon <aurelien.charbon@ext.bull.net>
> ---
> 
>  fs/nfsd/export.c               |   10 ++-
>  fs/nfsd/nfsctl.c               |   21 ++++++-
>  include/linux/sunrpc/svcauth.h |    4 -
>  include/net/ipv6.h             |   17 +++++
>  net/sunrpc/svcauth_unix.c      |  121 
> ++++++++++++++++++++++++++++-------------
>  5 files changed, 129 insertions(+), 44 deletions(-)
> 
> 
> diff -p -u -r -N linux-2.6.23-rc3/fs/nfsd/export.c 
> linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/export.c
> --- linux-2.6.23-rc3/fs/nfsd/export.c    2007-08-23 13:18:16.000000000 +0200
> +++ linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/export.c    2007-08-23 
> 13:51:08.000000000 +0200
> @@ -35,6 +35,7 @@
>  #include <linux/lockd/bind.h>
>  #include <linux/sunrpc/msg_prot.h>
>  #include <linux/sunrpc/gss_api.h>
> +#include <net/ipv6.h>
>  
>  #define NFSDDBG_FACILITY    NFSDDBG_EXPORT
>  
> @@ -1559,6 +1560,7 @@ exp_addclient(struct nfsctl_client *ncp)
>  {
>      struct auth_domain    *dom;
>      int            i, err;
> +    struct in6_addr addr6;
>  
>      /* First, consistency check. */
>      err = -EINVAL;
> @@ -1577,9 +1579,11 @@ exp_addclient(struct nfsctl_client *ncp)
>          goto out_unlock;
>  
>      /* Insert client into hashtable. */
> -    for (i = 0; i < ncp->cl_naddr; i++)
> -        auth_unix_add_addr(ncp->cl_addrlist[i], dom);
> -
> +    for (i = 0; i < ncp->cl_naddr; i++) {
> +        /* Mapping address */
> +        ipv6_addr_map(ncp->cl_addrlist[i], addr6);
> +        auth_unix_add_addr(addr6, dom);
> +    }
>      auth_unix_forget_old(dom);
>      auth_domain_put(dom);
>  
> diff -p -u -r -N linux-2.6.23-rc3/fs/nfsd/nfsctl.c 
> linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/nfsctl.c
> --- linux-2.6.23-rc3/fs/nfsd/nfsctl.c    2007-08-23 13:18:16.000000000 +0200
> +++ linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/nfsctl.c    2007-08-23 
> 13:25:28.000000000 +0200
> @@ -222,7 +222,7 @@ static ssize_t write_getfs(struct file *
>      struct auth_domain *clp;
>      int err = 0;
>      struct knfsd_fh *res;
> -
> +    struct in6_addr in6;
>      if (size < sizeof(*data))
>          return -EINVAL;
>      data = (struct nfsctl_fsparm*)buf;
> @@ -236,7 +236,14 @@ static ssize_t write_getfs(struct file *
>      res = (struct knfsd_fh*)buf;
>  
>      exp_readlock();
> -    if (!(clp = auth_unix_lookup(sin->sin_addr)))
> +
> +    /* IPv6 address mapping */
> +    in6.s6_addr32[0] = 0;
> +    in6.s6_addr32[1] = 0;
> +    in6.s6_addr32[2] = htonl(0xffff);
> +    in6.s6_addr32[3] = (uint32_t)sin->sin_addr.s_addr;
> +
> +    if (!(clp = auth_unix_lookup(in6)))
>          err = -EPERM;
>      else {
>          err = exp_rootfh(clp, data->gd_path, res, data->gd_maxlen);
> @@ -253,6 +260,7 @@ static ssize_t write_getfd(struct file *
>  {
>      struct nfsctl_fdparm *data;
>      struct sockaddr_in *sin;
> +    struct in6_addr in6;
>      struct auth_domain *clp;
>      int err = 0;
>      struct knfsd_fh fh;
> @@ -271,7 +279,14 @@ static ssize_t write_getfd(struct file *
>      res = buf;
>      sin = (struct sockaddr_in *)&data->gd_addr;
>      exp_readlock();
> -    if (!(clp = auth_unix_lookup(sin->sin_addr)))
> +
> +    /* IPv6 address mapping */
> +    in6.s6_addr32[0] = 0;
> +    in6.s6_addr32[1] = 0;
> +    in6.s6_addr32[2] = htonl(0xffff);
> +    in6.s6_addr32[3] = (uint32_t)sin->sin_addr.s_addr;

The code canonicalizes IPv4 addresses in several places.  Is there 
already a generic function defined somewhere to do this?  If not, it 
might make sense to add one.

[-- Attachment #2: chuck.lever.vcf --]
[-- Type: text/x-vcard, Size: 302 bytes --]

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard


^ permalink raw reply

* Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses
From: Brian Haley @ 2007-08-23 15:32 UTC (permalink / raw)
  To: Aurélien Charbon; +Cc: Mailing list NFSv4, netdev ML
In-Reply-To: <46CD890C.2040502@ext.bull.net>

Hi Aurelien,

Aurélien Charbon wrote:
> According to Neil's comments, I have tried to correct the mistakes of my 
> first sending

I have some more comments.

> @@ -1559,6 +1560,7 @@ exp_addclient(struct nfsctl_client *ncp)
> {
>     struct auth_domain    *dom;
>     int            i, err;
> +    struct in6_addr addr6;

Indentation looks wrong.

> diff -p -u -r -N linux-2.6.23-rc3/fs/nfsd/nfsctl.c 
> linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/nfsctl.c
> --- linux-2.6.23-rc3/fs/nfsd/nfsctl.c    2007-08-23 13:18:16.000000000 
> +0200
> +++ linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/nfsctl.c    2007-08-23 
> 13:25:28.000000000 +0200
> @@ -222,7 +222,7 @@ static ssize_t write_getfs(struct file *
>     struct auth_domain *clp;
>     int err = 0;
>     struct knfsd_fh *res;
> -
> +    struct in6_addr in6;

Indentation.

>     if (size < sizeof(*data))
>         return -EINVAL;
>     data = (struct nfsctl_fsparm*)buf;
> @@ -236,7 +236,14 @@ static ssize_t write_getfs(struct file *
>     res = (struct knfsd_fh*)buf;
> 
>     exp_readlock();
> -    if (!(clp = auth_unix_lookup(sin->sin_addr)))
> +
> +    /* IPv6 address mapping */
> +    in6.s6_addr32[0] = 0;
> +    in6.s6_addr32[1] = 0;
> +    in6.s6_addr32[2] = htonl(0xffff);
> +    in6.s6_addr32[3] = (uint32_t)sin->sin_addr.s_addr;

Why didn't you use your new ipv6_addr_map() inline here?

> @@ -253,6 +260,7 @@ static ssize_t write_getfd(struct file *
> {
>     struct nfsctl_fdparm *data;
>     struct sockaddr_in *sin;
> +    struct in6_addr in6;

Indentation.

> @@ -271,7 +279,14 @@ static ssize_t write_getfd(struct file *
>     res = buf;
>     sin = (struct sockaddr_in *)&data->gd_addr;
>     exp_readlock();
> -    if (!(clp = auth_unix_lookup(sin->sin_addr)))
> +
> +    /* IPv6 address mapping */
> +    in6.s6_addr32[0] = 0;
> +    in6.s6_addr32[1] = 0;
> +    in6.s6_addr32[2] = htonl(0xffff);
> +    in6.s6_addr32[3] = (uint32_t)sin->sin_addr.s_addr;

Why didn't you use your new ipv6_addr_map() inline here too?

> diff -p -u -r -N linux-2.6.23-rc3/include/net/ipv6.h 
> linux-2.6.23-rc3-IPv6-ipmap-cache/include/net/ipv6.h
> --- linux-2.6.23-rc3/include/net/ipv6.h    2007-08-23 13:18:23.000000000 
> +0200
> +++ linux-2.6.23-rc3-IPv6-ipmap-cache/include/net/ipv6.h    2007-08-23 
> 13:25:28.000000000 +0200
> @@ -21,6 +21,7 @@
> #include <net/ndisc.h>
> #include <net/flow.h>
> #include <net/snmp.h>
> +#include <linux/in.h>
> 
> #define SIN6_LEN_RFC2133    24
> 
> @@ -167,6 +168,12 @@ DECLARE_SNMP_STAT(struct udp_mib, udplit
>     if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, 
> field);         \
>     else        SNMP_INC_STATS_USER(udp_stats_in6, field);    } while(0)
> 
> +#define IS_ADDR_MAPPED(a) \
> +    (((uint32_t *) (a))[0] == 0            \
> +    && ((uint32_t *) (a))[1] == 0            \
> +    && (((uint32_t *) (a))[2] == 0            \
> +    || ((uint32_t *) (a))[2] == htonl(0xffff)))

I need to update a patch of mine that added a v4-mapped inline, let me 
send that out.  In the kernel you should use u32 too, is that why you 
needed to include linux/net.h?

> +/* Maps a IPv4 address into a wright IPv6 address */
> +static inline int ipv6_addr_map(const struct in_addr a1, struct 
> in6_addr a2)
> +{
> +    a2.s6_addr32[0] = 0;
> +    a2.s6_addr32[1] = 0;
> +    a2.s6_addr32[2] = htonl(0xffff);
> +    a2.s6_addr32[3] = (uint32_t)a1.s_addr;
> +    return 0;
> +}

This can be void, noone ever checks the return status.  Maybe change the 
name to ipv6_addr_v4map() too?

> @@ -84,7 +85,7 @@ static void svcauth_unix_domain_release(
> struct ip_map {
>     struct cache_head    h;
>     char            m_class[8]; /* e.g. "nfsd" */
> -    struct in_addr        m_addr;
> +    struct in6_addr        m_addr;

Indentation.

> static void ip_map_init(struct cache_head *cnew, struct cache_head *citem)
> {
> @@ -125,7 +133,7 @@ static void ip_map_init(struct cache_hea
>     struct ip_map *item = container_of(citem, struct ip_map, h);
> 
>     strcpy(new->m_class, item->m_class);
> -    new->m_addr.s_addr = item->m_addr.s_addr;
> +    memcpy(&(new->m_addr), &(item->m_addr), sizeof(struct in6_addr));

Use ipv6_addr_copy().

> @@ -151,20 +159,22 @@ static void ip_map_request(struct cache_
> {
>     char text_addr[20];
>     struct ip_map *im = container_of(h, struct ip_map, h);
> -    __be32 addr = im->m_addr.s_addr;
> -
> -    snprintf(text_addr, 20, "%u.%u.%u.%u",
> -         ntohl(addr) >> 24 & 0xff,
> -         ntohl(addr) >> 16 & 0xff,
> -         ntohl(addr) >>  8 & 0xff,
> -         ntohl(addr) >>  0 & 0xff);
> 
> +    if (IS_ADDR_MAPPED(im->m_addr.s6_addr32)) {
> +        snprintf(text_addr, 20, NIPQUAD_FMT,
> +                ntohl(im->m_addr.s6_addr32[3]) >> 24 & 0xff,
> +                ntohl(im->m_addr.s6_addr32[3]) >> 16 & 0xff,
> +                ntohl(im->m_addr.s6_addr32[3]) >>  8 & 0xff,
> +                ntohl(im->m_addr.s6_addr32[3]) >>  0 & 0xff);
> +    } else {
> +        snprintf(text_addr, 20, NIP6_FMT, NIP6(im->m_addr));
> +    }

You'll need more than 20 bytes to print an IPv6 address, I'd make this 
at least 44 to account for some fluff.  Surprised you didn't crash 
during testing.

> static int ip_map_parse(struct cache_detail *cd,
> @@ -175,10 +185,10 @@ static int ip_map_parse(struct cache_det
>      * for scratch: */
>     char *buf = mesg;
>     int len;
> -    int b1,b2,b3,b4;
> +    int b1, b2, b3, b4, b5, b6, b7, b8;
>     char c;
>     char class[8];
> -    struct in_addr addr;
> +    struct in6_addr addr;
>     int err;

You might as well fix the indentation while you're here.

> @@ -238,7 +262,7 @@ static int ip_map_show(struct seq_file *
>                struct cache_head *h)
> {
>     struct ip_map *im;
> -    struct in_addr addr;
> +    struct in6_addr addr;

Indentation.

>     if (h == NULL) {
> @@ -247,20 +271,33 @@ static int ip_map_show(struct seq_file *
>     }
>     im = container_of(h, struct ip_map, h);
>     /* class addr domain */
> -    addr = im->m_addr;
> +    memcpy(&addr, &im->m_addr, sizeof(struct in6_addr));

ipv6_addr_copy()

> -    seq_printf(m, "%s %d.%d.%d.%d %s\n",
> -           im->m_class,
> -           ntohl(addr.s_addr) >> 24 & 0xff,
> -           ntohl(addr.s_addr) >> 16 & 0xff,
> -           ntohl(addr.s_addr) >>  8 & 0xff,
> -           ntohl(addr.s_addr) >>  0 & 0xff,
> -           dom
> -           );
> +    if (IS_ADDR_MAPPED(addr.s6_addr32)) {
> +        seq_printf(m, "%s" NIPQUAD_FMT "%s\n",
> +            im->m_class,
> +            ntohl(addr.s6_addr32[3]) >> 24 & 0xff,
> +            ntohl(addr.s6_addr32[3]) >> 16 & 0xff,
> +            ntohl(addr.s6_addr32[3]) >>  8 & 0xff,
> +            ntohl(addr.s6_addr32[3]) >>  0 & 0xff,
> +            dom);
> +    } else {
> +        seq_printf(m, "%s" NIP6_FMT "%s\n",
> +            im->m_class,
> +            ntohl(addr.s6_addr16[7]),
> +            ntohl(addr.s6_addr16[6]),
> +            ntohl(addr.s6_addr16[5]),
> +            ntohl(addr.s6_addr16[4]),
> +            ntohl(addr.s6_addr16[3]),
> +            ntohl(addr.s6_addr16[2]),
> +            ntohl(addr.s6_addr16[1]),
> +            ntohl(addr.s6_addr16[0]),
> +            dom);

These should be ntohs(), it's only a 16-bit quantity.  Also, don't you 
want to start printing this at addr[0], not addr[7]?

> -static struct ip_map *ip_map_lookup(char *class, struct in_addr addr)
> +static struct ip_map *ip_map_lookup(char *class, struct in6_addr addr)
> {
>     struct ip_map ip;
>     struct cache_head *ch;
> 
>     strcpy(ip.m_class, class);
> -    ip.m_addr = addr;
> +    memcpy(&ip.m_addr, &addr, sizeof(struct in6_addr));

ipv6_addr_copy()

-Brian

^ permalink raw reply

* [PATCH] [-MM, FIX] e1000e: incorporate napi_struct changes from net-2.6.24.git
From: Auke Kok @ 2007-08-23 14:59 UTC (permalink / raw)
  To: akpm; +Cc: davem, jeff, shemminger, netdev, krkumar2

This incorporates the new napi_struct changes into e1000e. Included
bugfix for ifdown hang from Krishna Kumar for e1000.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---

 drivers/net/e1000e/e1000.h  |    2 ++
 drivers/net/e1000e/netdev.c |   35 ++++++++++++++++-------------------
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index e3cd877..ea6a9fe 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -196,6 +196,8 @@ struct e1000_adapter {
 	struct e1000_ring *tx_ring /* One per active queue */
 						____cacheline_aligned_in_smp;
 
+	struct napi_struct napi;
+
 	unsigned long tx_queue_len;
 	unsigned int restart_queue;
 	u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 8ebe238..0e35d0a 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
 			mod_timer(&adapter->watchdog_timer, jiffies + 1);
 	}
 
-	if (netif_rx_schedule_prep(netdev)) {
+	if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
 		adapter->total_tx_bytes = 0;
 		adapter->total_tx_packets = 0;
 		adapter->total_rx_bytes = 0;
 		adapter->total_rx_packets = 0;
-		__netif_rx_schedule(netdev);
+		__netif_rx_schedule(netdev, &adapter->napi);
 	} else {
 		atomic_dec(&adapter->irq_sem);
 	}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
 			mod_timer(&adapter->watchdog_timer, jiffies + 1);
 	}
 
-	if (netif_rx_schedule_prep(netdev)) {
+	if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
 		adapter->total_tx_bytes = 0;
 		adapter->total_tx_packets = 0;
 		adapter->total_rx_bytes = 0;
 		adapter->total_rx_packets = 0;
-		__netif_rx_schedule(netdev);
+		__netif_rx_schedule(netdev, &adapter->napi);
 	} else {
 		atomic_dec(&adapter->irq_sem);
 	}
@@ -1663,10 +1663,10 @@ set_itr_now:
  * e1000_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
 {
-	struct e1000_adapter *adapter;
-	int work_to_do = min(*budget, poll_dev->quota);
+	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
+	struct net_device *poll_dev = adapter->netdev;
 	int tx_cleaned = 0, work_done = 0;
 
 	/* Must NOT use netdev_priv macro here. */
@@ -1685,17 +1685,15 @@ static int e1000_clean(struct net_device *poll_dev, int *budget)
 		spin_unlock(&adapter->tx_queue_lock);
 	}
 
-	adapter->clean_rx(adapter, &work_done, work_to_do);
-	*budget -= work_done;
-	poll_dev->quota -= work_done;
+	adapter->clean_rx(adapter, &work_done, budget);
 
 	/* If no Tx and not enough Rx work done, exit the polling mode */
-	if ((!tx_cleaned && (work_done == 0)) ||
+	if ((tx_cleaned && (work_done < budget)) ||
 	   !netif_running(poll_dev)) {
 quit_polling:
 		if (adapter->itr_setting & 3)
 			e1000_set_itr(adapter);
-		netif_rx_complete(poll_dev);
+		netif_rx_complete(poll_dev, napi);
 		if (test_bit(__E1000_DOWN, &adapter->state))
 			atomic_dec(&adapter->irq_sem);
 		else
@@ -1703,7 +1701,7 @@ quit_polling:
 		return 0;
 	}
 
-	return 1;
+	return work_done;
 }
 
 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2441,7 +2439,7 @@ int e1000e_up(struct e1000_adapter *adapter)
 
 	clear_bit(__E1000_DOWN, &adapter->state);
 
-	netif_poll_enable(adapter->netdev);
+	napi_enable(&adapter->napi);
 	e1000_irq_enable(adapter);
 
 	/* fire a link change interrupt to start the watchdog */
@@ -2474,7 +2472,7 @@ void e1000e_down(struct e1000_adapter *adapter)
 	e1e_flush();
 	msleep(10);
 
-	netif_poll_disable(netdev);
+	napi_disable(&adapter->napi);
 	e1000_irq_disable(adapter);
 
 	del_timer_sync(&adapter->watchdog_timer);
@@ -2607,7 +2605,7 @@ static int e1000_open(struct net_device *netdev)
 	/* From here on the code is the same as e1000e_up() */
 	clear_bit(__E1000_DOWN, &adapter->state);
 
-	netif_poll_enable(netdev);
+	napi_enable(&adapter->napi);
 
 	e1000_irq_enable(adapter);
 
@@ -4102,8 +4100,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 	e1000e_set_ethtool_ops(netdev);
 	netdev->tx_timeout		= &e1000_tx_timeout;
 	netdev->watchdog_timeo		= 5 * HZ;
-	netdev->poll			= &e1000_clean;
-	netdev->weight			= 64;
+	netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
 	netdev->vlan_rx_register	= e1000_vlan_rx_register;
 	netdev->vlan_rx_add_vid		= e1000_vlan_rx_add_vid;
 	netdev->vlan_rx_kill_vid	= e1000_vlan_rx_kill_vid;
@@ -4272,7 +4269,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 	/* tell the stack to leave us alone until e1000_open() is called */
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
-	netif_poll_disable(netdev);
+	napi_disable(&adapter->napi);
 
 	strcpy(netdev->name, "eth%d");
 	err = register_netdev(netdev);

^ permalink raw reply related

* Re: [PATCH 1/1] net/core: Fix crash in dev_mc_sync()/dev_mc_unsync()
From: Patrick McHardy @ 2007-08-23 14:48 UTC (permalink / raw)
  To: Benjamin Thery; +Cc: netdev, David Miller
In-Reply-To: <46CC3840.7050300@bull.net>

Benjamin Thery wrote:
> From: benjamin.thery@bull.net
> Subject: net/core: Fix crash in dev_mc_sync()/dev_mc_unsync()
> 
> This patch fixes a crash that may occur when the routine dev_mc_sync()
> deletes an address from the list it is currently going through. It 
> saves the pointer to the next element before deleting the current one.
> The problem may also exist in dev_mc_unsync().
> 
> Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>

Looks good, thanks Benjamin.

Acked-by: Patrick McHardy <kaber@trash.net>


^ 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