@@ -158,10 +158,16 @@ struct packet_mreq_max {
158
158
unsigned char mr_address [MAX_ADDR_LEN ];
159
159
};
160
160
161
+ union tpacket_uhdr {
162
+ struct tpacket_hdr * h1 ;
163
+ struct tpacket2_hdr * h2 ;
164
+ struct tpacket3_hdr * h3 ;
165
+ void * raw ;
166
+ };
167
+
161
168
static int packet_set_ring (struct sock * sk , union tpacket_req_u * req_u ,
162
169
int closing , int tx_ring );
163
170
164
-
165
171
#define V3_ALIGNMENT (8)
166
172
167
173
#define BLK_HDR_LEN (ALIGN(sizeof(struct tpacket_block_desc), V3_ALIGNMENT))
@@ -290,11 +296,7 @@ static inline __pure struct page *pgv_to_page(void *addr)
290
296
291
297
static void __packet_set_status (struct packet_sock * po , void * frame , int status )
292
298
{
293
- union {
294
- struct tpacket_hdr * h1 ;
295
- struct tpacket2_hdr * h2 ;
296
- void * raw ;
297
- } h ;
299
+ union tpacket_uhdr h ;
298
300
299
301
h .raw = frame ;
300
302
switch (po -> tp_version ) {
@@ -317,11 +319,7 @@ static void __packet_set_status(struct packet_sock *po, void *frame, int status)
317
319
318
320
static int __packet_get_status (struct packet_sock * po , void * frame )
319
321
{
320
- union {
321
- struct tpacket_hdr * h1 ;
322
- struct tpacket2_hdr * h2 ;
323
- void * raw ;
324
- } h ;
322
+ union tpacket_uhdr h ;
325
323
326
324
smp_rmb ();
327
325
@@ -347,11 +345,7 @@ static void *packet_lookup_frame(struct packet_sock *po,
347
345
int status )
348
346
{
349
347
unsigned int pg_vec_pos , frame_offset ;
350
- union {
351
- struct tpacket_hdr * h1 ;
352
- struct tpacket2_hdr * h2 ;
353
- void * raw ;
354
- } h ;
348
+ union tpacket_uhdr h ;
355
349
356
350
pg_vec_pos = position / rb -> frames_per_block ;
357
351
frame_offset = position % rb -> frames_per_block ;
@@ -1669,12 +1663,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
1669
1663
struct sock * sk ;
1670
1664
struct packet_sock * po ;
1671
1665
struct sockaddr_ll * sll ;
1672
- union {
1673
- struct tpacket_hdr * h1 ;
1674
- struct tpacket2_hdr * h2 ;
1675
- struct tpacket3_hdr * h3 ;
1676
- void * raw ;
1677
- } h ;
1666
+ union tpacket_uhdr h ;
1678
1667
u8 * skb_head = skb -> data ;
1679
1668
int skb_len = skb -> len ;
1680
1669
unsigned int snaplen , res ;
@@ -1909,11 +1898,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
1909
1898
void * frame , struct net_device * dev , int size_max ,
1910
1899
__be16 proto , unsigned char * addr , int hlen )
1911
1900
{
1912
- union {
1913
- struct tpacket_hdr * h1 ;
1914
- struct tpacket2_hdr * h2 ;
1915
- void * raw ;
1916
- } ph ;
1901
+ union tpacket_uhdr ph ;
1917
1902
int to_write , offset , len , tp_len , nr_frags , len_max ;
1918
1903
struct socket * sock = po -> sk .sk_socket ;
1919
1904
struct page * page ;
0 commit comments