netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]
@ 2003-07-08 22:16 Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2003-07-08 22:16 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Convert Digi RigtSwitch to use alloc_etherdev.

Builds (on 2.5.74) but once again, do not have real hardware to test.

diff -Nru a/drivers/net/dgrs.c b/drivers/net/dgrs.c
--- a/drivers/net/dgrs.c	Mon Jul  7 14:50:36 2003
+++ b/drivers/net/dgrs.c	Mon Jul  7 14:50:36 2003
@@ -1252,18 +1252,12 @@
 {
 	DGRS_PRIV	*priv;
 	struct net_device *dev, *aux;
-
-	/* Allocate and fill new device structure. */
-	int dev_size = sizeof(struct net_device) + sizeof(DGRS_PRIV);
 	int i, ret;
 
-	dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL);
-
+	dev = alloc_etherdev(sizeof(DGRS_PRIV));
 	if (!dev)
 		return -ENOMEM;
 
-	memset(dev, 0, dev_size);
-	dev->priv = ((void *)dev) + sizeof(struct net_device);
 	priv = (DGRS_PRIV *)dev->priv;
 
 	dev->base_addr = io;
@@ -1279,7 +1273,7 @@
 
 	dev->init = dgrs_probe1;
 	SET_MODULE_OWNER(dev);
-	ether_setup(dev);
+
 	if (register_netdev(dev) != 0) {
 		kfree(dev);
 		return -EIO;
@@ -1302,15 +1296,18 @@
 		struct net_device	*devN;
 		DGRS_PRIV	*privN;
 			/* Allocate new dev and priv structures */
-		devN = (struct net_device *) kmalloc(dev_size, GFP_KERNEL);
-			/* Make it an exact copy of dev[0]... */
+		devN = alloc_etherdev(sizeof(DGRS_PRIV));
 		ret = -ENOMEM;
 		if (!devN) 
 			goto fail;
-		memcpy(devN, dev, dev_size);
-		memset(devN->name, 0, sizeof(devN->name));
-		devN->priv = ((void *)devN) + sizeof(struct net_device);
+
+		/* Make it an exact copy of dev[0]... */
+		*devN = *dev;
+
+		/* copy the priv structure of dev[0] */
 		privN = (DGRS_PRIV *)devN->priv;
+		*privN = *priv;
+
 			/* ... and zero out VM areas */
 		privN->vmem = 0;
 		privN->vplxdma = 0;
@@ -1318,9 +1315,11 @@
 		devN->irq = 0;
 			/* ... and base MAC address off address of 1st port */
 		devN->dev_addr[5] += i;
+			/* ... choose a new name */
+		strncpy(devN->name, "eth%d", IFNAMSIZ);
 		devN->init = dgrs_initclone;
 		SET_MODULE_OWNER(devN);
-		ether_setup(devN);
+
 		ret = -EIO;
 		if (register_netdev(devN)) {
 			kfree(devN);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH]
@ 2003-11-13  0:39 Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2003-11-13  0:39 UTC (permalink / raw)
  To: intro, jgarzik; +Cc: netdev

This is the update to Al viro's changes to probing to have all
network devices use dynamic allocation.  The patches are against
net-drivers-2.5-exp.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH]
@ 2003-12-27 13:50 Bart De Schuymer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart De Schuymer @ 2003-12-27 13:50 UTC (permalink / raw)
  To: David S.Miller; +Cc: netdev, Stephen Hemminger

Hi Dave,

We should also filter vlan-tagged IP/ARP traffic even if the vlan code
isn't compiled into the kernel. The patch below removes an unnecessary
dependence on the vlan code being compiled.

cheers,
Bart


--- linux-2.6.0/include/linux/netfilter_bridge.h.earlier	2003-12-25 17:01:38.000000000 +0100
+++ linux-2.6.0/include/linux/netfilter_bridge.h	2003-12-25 17:02:56.000000000 +0100
@@ -71,12 +71,10 @@ static inline
 void nf_bridge_maybe_copy_header(struct sk_buff *skb)
 {
 	if (skb->nf_bridge) {
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 		if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
 			memcpy(skb->data - 18, skb->nf_bridge->data, 18);
 			skb_push(skb, 4);
 		} else
-#endif
 			memcpy(skb->data - 16, skb->nf_bridge->data, 16);
 	}
 }
@@ -86,10 +84,9 @@ void nf_bridge_save_header(struct sk_buf
 {
         int header_size = 16;
 
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 	if (skb->protocol == __constant_htons(ETH_P_8021Q))
 		header_size = 18;
-#endif
+
 	memcpy(skb->nf_bridge->data, skb->data - header_size, header_size);
 }
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH]
  2013-09-26 14:09 ` [PATCH net-next v3 1/3] flow_dissector: factor out the ports extraction in skb_flow_get_ports Nikolay Aleksandrov
@ 2013-09-26 15:27   ` Eric Dumazet
  2013-09-26 15:40     ` [PATCH] Nikolay Aleksandrov
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2013-09-26 15:27 UTC (permalink / raw)
  To: Nikolay Aleksandrov, Daniel Borkmann; +Cc: netdev, davem, andy, fubar, vfalico

On Thu, 2013-09-26 at 16:09 +0200, Nikolay Aleksandrov wrote:
> Factor out the code that extracts the ports from skb_flow_dissect and
> add a new function skb_flow_get_ports which can be re-used.
> 
> Suggested-by: Veaceslav Falico <vfalico@redhat.com>
> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
> ---
> v2: new patch
> v3: fix a bug in skb_flow_dissect where thoff didn't have poff added by
>     modifying thoff directly in skb_flow_get_ports as it's done anyway.
>     Also add the necessary export symbol for skb_flow_get_ports.
> This seems like a good idea because there're other users that can re-use
> it later as well.

Wait a minute.... existing code seems buggy.

Daniel, any objection if I submit this fix ?

(commit 8ed781668dd49b608f)

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 1929af8..8d7d0dd 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -154,8 +154,8 @@ ipv6:
 	if (poff >= 0) {
 		__be32 *ports, _ports;
 
-		nhoff += poff;
-		ports = skb_header_pointer(skb, nhoff, sizeof(_ports), &_ports);
+		ports = skb_header_pointer(skb, nhoff + poff,
+					   sizeof(_ports), &_ports);
 		if (ports)
 			flow->ports = *ports;
 	}

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH]
  2013-09-26 15:27   ` [PATCH] Eric Dumazet
@ 2013-09-26 15:40     ` Nikolay Aleksandrov
  2013-09-26 15:44       ` [PATCH] Nikolay Aleksandrov
  2013-09-26 15:53       ` [PATCH] Eric Dumazet
  0 siblings, 2 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2013-09-26 15:40 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Daniel Borkmann, netdev, davem, andy, fubar, vfalico

On 09/26/2013 05:27 PM, Eric Dumazet wrote:
> On Thu, 2013-09-26 at 16:09 +0200, Nikolay Aleksandrov wrote:
>> Factor out the code that extracts the ports from skb_flow_dissect and
>> add a new function skb_flow_get_ports which can be re-used.
>>
>> Suggested-by: Veaceslav Falico <vfalico@redhat.com>
>> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
>> ---
>> v2: new patch
>> v3: fix a bug in skb_flow_dissect where thoff didn't have poff added by
>>     modifying thoff directly in skb_flow_get_ports as it's done anyway.
>>     Also add the necessary export symbol for skb_flow_get_ports.
>> This seems like a good idea because there're other users that can re-use
>> it later as well.
> 
> Wait a minute.... existing code seems buggy.
> 
> Daniel, any objection if I submit this fix ?
> 
> (commit 8ed781668dd49b608f)
> 
1 question, I might be missing something but proto_ports_offset() gets the SPI
with that 4 byte offset as is written in the comments, in every other case
proto_ports_offset() is 0, so why would we want the SPI in the ->ports field ?
And even then isn't it supposed to be 16 bits (2 bytes) and not 4, since we need
to pass over "next header" (8 bits) and length (8 bits) ?

Thanks,
 Nik

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]
  2013-09-26 15:40     ` [PATCH] Nikolay Aleksandrov
@ 2013-09-26 15:44       ` Nikolay Aleksandrov
  2013-09-26 15:53       ` [PATCH] Eric Dumazet
  1 sibling, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2013-09-26 15:44 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Daniel Borkmann, netdev, davem, andy, fubar, vfalico

On 09/26/2013 05:40 PM, Nikolay Aleksandrov wrote:
> On 09/26/2013 05:27 PM, Eric Dumazet wrote:
>> On Thu, 2013-09-26 at 16:09 +0200, Nikolay Aleksandrov wrote:
>>> Factor out the code that extracts the ports from skb_flow_dissect and
>>> add a new function skb_flow_get_ports which can be re-used.
>>>
>>> Suggested-by: Veaceslav Falico <vfalico@redhat.com>
>>> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
>>> ---
>>> v2: new patch
>>> v3: fix a bug in skb_flow_dissect where thoff didn't have poff added by
>>>     modifying thoff directly in skb_flow_get_ports as it's done anyway.
>>>     Also add the necessary export symbol for skb_flow_get_ports.
>>> This seems like a good idea because there're other users that can re-use
>>> it later as well.
>>
>> Wait a minute.... existing code seems buggy.
>>
>> Daniel, any objection if I submit this fix ?
>>
>> (commit 8ed781668dd49b608f)
>>
> 1 question, I might be missing something but proto_ports_offset() gets the SPI
> with that 4 byte offset as is written in the comments, in every other case
> proto_ports_offset() is 0, so why would we want the SPI in the ->ports field ?
> And even then isn't it supposed to be 16 bits (2 bytes) and not 4, since we need
> to pass over "next header" (8 bits) and length (8 bits) ?
> 
Nevermind the second part, I forgot about the 16-bit 0 region :-)

> Thanks,
>  Nik

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH]
  2013-09-26 15:40     ` [PATCH] Nikolay Aleksandrov
  2013-09-26 15:44       ` [PATCH] Nikolay Aleksandrov
@ 2013-09-26 15:53       ` Eric Dumazet
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2013-09-26 15:53 UTC (permalink / raw)
  To: Nikolay Aleksandrov; +Cc: Daniel Borkmann, netdev, davem, andy, fubar, vfalico

On Thu, 2013-09-26 at 17:40 +0200, Nikolay Aleksandrov wrote:
> > 
> 1 question, I might be missing something but proto_ports_offset() gets the SPI
> with that 4 byte offset as is written in the comments, in every other case
> proto_ports_offset() is 0, so why would we want the SPI in the ->ports field ?
> And even then isn't it supposed to be 16 bits (2 bytes) and not 4, since we need
> to pass over "next header" (8 bits) and length (8 bits) ?

struct ip_auth_hdr {
        __u8  nexthdr;
        __u8  hdrlen;           /* This one is measured in 32 bit units! */
        __be16 reserved;
        __be32 spi;
        __be32 seq_no;          /* Sequence number */
        __u8  auth_data[0];     /* Variable len but >=4. Mind the 64 bit alignment! */
};

offsetof(spi, struct ...) = 4

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-09-26 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-13  0:39 [PATCH] Stephen Hemminger
  -- strict thread matches above, loose matches on Subject: below --
2013-09-26 14:09 [PATCH net-next v3 0/3] bonding: modify the current and add new hash functions Nikolay Aleksandrov
2013-09-26 14:09 ` [PATCH net-next v3 1/3] flow_dissector: factor out the ports extraction in skb_flow_get_ports Nikolay Aleksandrov
2013-09-26 15:27   ` [PATCH] Eric Dumazet
2013-09-26 15:40     ` [PATCH] Nikolay Aleksandrov
2013-09-26 15:44       ` [PATCH] Nikolay Aleksandrov
2013-09-26 15:53       ` [PATCH] Eric Dumazet
2003-12-27 13:50 [PATCH] Bart De Schuymer
2003-07-08 22:16 [PATCH] Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).