Skip to content

Commit

Permalink
[NET]: Annotate h_proto in struct ethhdr
Browse files Browse the repository at this point in the history
The protocol field in ethernet headers is big-endian and should be
annotated as such.  This patch allows detection of missing ntohs() calls
on the ethernet protocol field when sparse is run with __CHECK_ENDIAN__
defined.

This is a revised version that includes <linux/types.h> so that the
userspace programs are not confused by __be16.  Thanks to David S.
Miller.

Signed-off-by: Pavel Roskin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Pavel Roskin authored and davem330 committed Nov 10, 2005
1 parent fb286bb commit ac57d04
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/linux/if_ether.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef _LINUX_IF_ETHER_H
#define _LINUX_IF_ETHER_H

#include <linux/types.h>

/*
* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
* and FCS/CRC (frame check sequence).
Expand Down Expand Up @@ -100,7 +102,7 @@
struct ethhdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
unsigned char h_source[ETH_ALEN]; /* source ether addr */
unsigned short h_proto; /* packet type ID field */
__be16 h_proto; /* packet type ID field */
} __attribute__((packed));

#ifdef __KERNEL__
Expand Down

0 comments on commit ac57d04

Please sign in to comment.