Skip to contentSkip to conversation

net/core: use htons for skb->protocol

PATCH Superseded Sebastian Andrzej Siewior 3 participants 5 messages Jun 29, 2010 – Jun 30, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/core: use htons for skb->protocol

From: Sebastian Andrzej Siewior <[email protected]>

This is only noticed by people that are not doing everything correct in the first place.

---
 net/core/dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/core/dev.c +2 -1
index 2b3bf53..78ad37c 100644
@@ -1541,7 +1541,8 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 				if (net_ratelimit())
 					printk(KERN_CRIT "protocol %04x is "
 					       "buggy, dev %s\n",
-					       skb2->protocol, dev->name);
+					       htons(skb2->protocol),
+					       dev->name);
 				skb_reset_network_header(skb2);
 			}
 
Signature · 1 line
1.7.0.4
#4 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 15 lines · Sebastian Andrzej Siewior

From: Sebastian Andrzej Siewior<[email protected]>

This is only noticed by people that are not doing everything correct in the first place.

---
  net/core/dev.c |    3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)
net/core/dev.c +0 -0
index 2b3bf53..78ad37c 100644

net/core/dev.c static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) · line 1544

Quoted 5 lines
net/core/dev.c +1 -1
@@ -1541,7 +1541,8 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
  				if (net_ratelimit())
  					printk(KERN_CRIT "protocol %04x is "
  					       "buggy, dev %s\n",
-					       skb2->protocol, dev->name);
+					       htons(skb2->protocol),

Would ntohs() be more appropriate here? It looks like you are converting from network order to host order for printing.

David Daney

#2 lore raw

PATCH v2 1/1 net/core: use ntohs for skb->protocol

In reply to David Miller

From: Sebastian Andrzej Siewior <[email protected]>

This is only noticed by people that are not doing everything correct in the first place.

---
 net/core/dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/core/dev.c +2 -1
index eb4be99..8e61dc5 100644
@@ -1537,7 +1537,8 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 				if (net_ratelimit())
 					printk(KERN_CRIT "protocol %04x is "
 					       "buggy, dev %s\n",
-					       skb2->protocol, dev->name);
+					       ntohs(skb2->protocol),
+					       dev->name);
 				skb_reset_network_header(skb2);
 			}
 
Signature · 1 line
1.6.6.1