From: "David S. Miller" <[EMAIL PROTECTED]>
Subject: Re: [PATCH] Packet socket: fix for 64-bit kernel and 32-bit userland
Date: Tue, 07 Feb 2006 21:48:02 -0800 (PST)
> From: FUJITA Tomonori <[EMAIL PROTECTED]>
> Date: Wed, 08 Feb 2006 14:41:41 +0900
>
> > From: "David S. Miller" <[EMAIL PROTECTED]>
> > Subject: Re: [PATCH] Packet socket: fix for 64-bit kernel and 32-bit
> > userland
> > Date: Tue, 07 Feb 2006 21:36:06 -0800 (PST)
> >
> > > > tpacket_hdr structure includes 'unsigned long' though kernel and
> > > > userland shares it in the mmapped ring buffer.
> > > >
> > > > Seems it would be better to fix all data structures in the header file
> > > > than fixing only tpacket_hdr structure.
> > > >
> > > > Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]>
> > > > Signed-off-by: Mike Christie <[EMAIL PROTECTED]>
> > >
> > > You broke 64-bit userland by changing that "unsigned long"
> > > to a __u32.
> >
> > You mean that currently it's broken in 64-bit kernel and 32-bit
> > userland anyway so use __u64 instead of __u32?
>
> I mean that "unsigned long" is 64-bit in a 64-bit kernel, and thus
> your changes break packet mmap() ringer buffers for native 64-bit
> binaries.
I see. The following patch is OK?
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
index b925585..0fc6998 100644
--- a/include/linux/if_packet.h
+++ b/include/linux/if_packet.h
@@ -3,20 +3,20 @@
struct sockaddr_pkt
{
- unsigned short spkt_family;
- unsigned char spkt_device[14];
- unsigned short spkt_protocol;
+ __u16 spkt_family;
+ __u8 spkt_device[14];
+ __u16 spkt_protocol;
};
struct sockaddr_ll
{
- unsigned short sll_family;
- unsigned short sll_protocol;
- int sll_ifindex;
- unsigned short sll_hatype;
- unsigned char sll_pkttype;
- unsigned char sll_halen;
- unsigned char sll_addr[8];
+ __u16 sll_family;
+ __u16 sll_protocol;
+ __s32 sll_ifindex;
+ __u16 sll_hatype;
+ __u8 sll_pkttype;
+ __u8 sll_halen;
+ __u8 sll_addr[8];
};
/* Packet types */
@@ -42,24 +42,24 @@ struct sockaddr_ll
struct tpacket_stats
{
- unsigned int tp_packets;
- unsigned int tp_drops;
+ __u32 tp_packets;
+ __u32 tp_drops;
};
struct tpacket_hdr
{
- unsigned long tp_status;
+ __u64 tp_status;
#define TP_STATUS_KERNEL 0
#define TP_STATUS_USER 1
#define TP_STATUS_COPY 2
#define TP_STATUS_LOSING 4
#define TP_STATUS_CSUMNOTREADY 8
- unsigned int tp_len;
- unsigned int tp_snaplen;
- unsigned short tp_mac;
- unsigned short tp_net;
- unsigned int tp_sec;
- unsigned int tp_usec;
+ __u32 tp_len;
+ __u32 tp_snaplen;
+ __u16 tp_mac;
+ __u16 tp_net;
+ __u32 tp_sec;
+ __u32 tp_usec;
};
#define TPACKET_ALIGNMENT 16
@@ -81,18 +81,18 @@ struct tpacket_hdr
struct tpacket_req
{
- unsigned int tp_block_size; /* Minimal size of contiguous block */
- unsigned int tp_block_nr; /* Number of blocks */
- unsigned int tp_frame_size; /* Size of frame */
- unsigned int tp_frame_nr; /* Total number of frames */
+ __u32 tp_block_size; /* Minimal size of contiguous block */
+ __u32 tp_block_nr; /* Number of blocks */
+ __u32 tp_frame_size; /* Size of frame */
+ __u32 tp_frame_nr; /* Total number of frames */
};
struct packet_mreq
{
- int mr_ifindex;
- unsigned short mr_type;
- unsigned short mr_alen;
- unsigned char mr_address[8];
+ __s32 mr_ifindex;
+ __u16 mr_type;
+ __u16 mr_alen;
+ __u8 mr_address[8];
};
#define PACKET_MR_MULTICAST 0
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html