Re: [PATCH v2 net-next af-packet 1/2] Enhance af-packet to provide(near zero)lossless packet capture functionality.

From: David Miller
Date: Fri Jul 01 2011 - 18:36:42 EST


From: Chetan Loke <loke.chetan@xxxxxxxxx>
Date: Tue, 21 Jun 2011 22:10:49 -0400

> +struct bd_v1 {
-
> + __u32 block_status;
> + __u32 num_pkts;
> + __u32 offset_to_first_pkt;
-
> + __u32 blk_len;
-
> + __u64 seq_num;
...
> + union {
> + struct {
> + __u32 words[4];
> + __u64 dword;
> + } __attribute__ ((__packed__));
> + struct bd_v1 bd1;
...
> +#define BLOCK_STATUS(x) ((x)->words[0])
> +#define BLOCK_NUM_PKTS(x) ((x)->words[1])
> +#define BLOCK_O2FP(x) ((x)->words[2])
> +#define BLOCK_LEN(x) ((x)->words[3])
> +#define BLOCK_SNUM(x) ((x)->dword)

This BLOCK_SNUM definition is buggy. It modifies the
first 64-bit word in the block descriptor.

But the sequence number lives 16 bytes into the descriptor.

This value is only written to once and never used by anything.
I would just remove it entirely.

Next, having this overlay thing is entirely pointless. Just refer to
the block descriptor members directly! You certainly wouldn't have
had this sequence number bug if you had done that.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/