[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 01/12] net: eth: Add a helper to pad a short Ethernet fram
From: |
Bin Meng |
Subject: |
Re: [PATCH v4 01/12] net: eth: Add a helper to pad a short Ethernet frame |
Date: |
Wed, 17 Mar 2021 14:22:47 +0800 |
On Tue, Mar 16, 2021 at 11:09 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> On 3/16/21 1:04 PM, Bin Meng wrote:
> > Add a helper to pad a short Ethernet frame to the minimum required
> > length, which can be used by backend codes.
>
> "backend codes" sounds odd but I'm not native English speaker.
> I'd have used "backends' code" instead...
>
Will update in v5.
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > ---
> >
> > Changes in v4:
> > - change 'ethernet' to 'Ethernet'
> > - do not inline the helper
> > - check the padded buffer size to avoid buffer overflow
> >
> > Changes in v3:
> > - use 'without' instead of 'sans'
> > - add a helper to pad short frames
> >
> > include/net/eth.h | 17 +++++++++++++++++
> > net/eth.c | 17 +++++++++++++++++
> > 2 files changed, 34 insertions(+)
> >
> > diff --git a/include/net/eth.h b/include/net/eth.h
> > index 0671be6916..6aabbdd0d3 100644
> > --- a/include/net/eth.h
> > +++ b/include/net/eth.h
> > @@ -31,6 +31,7 @@
> >
> > #define ETH_ALEN 6
> > #define ETH_HLEN 14
> > +#define ETH_ZLEN 60 /* Min. octets in frame without FCS */
> >
> > struct eth_header {
> > uint8_t h_dest[ETH_ALEN]; /* destination eth addr */
> > @@ -422,4 +423,20 @@ bool
> > eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_frags,
> > size_t ip6hdr_off, eth_ip6_hdr_info *info);
> >
> > +/**
> > + * eth_pad_short_frame - pad a short frame to the minimum Ethernet frame
> > length
> > + *
> > + * If the Ethernet frame size is shorter than 60 bytes, it will be padded
> > to
> > + * 60 bytes at the address @padded_pkt.
> > + *
> > + * @padded_pkt: buffer address to hold the padded frame
> > + * @padded_buflen: buffer length of @padded_pkt. If the frame is padded,
> > it is
> > + * written to ETH_ZLEN, otherwise it remains unchanged.
>
> @padded_buflen: pointer holding length of @padded_pkt. If the frame is
> padded, the length will be updated to the padded one.
Will update in v5.
>
> Otherwise:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> (since you describe frames, maybe s/pkt/frame/?)
>
By looking at the existing codes, 'pkt' seems to be a common variable
name representing ethernet frames, hence I will keep this as it is.
Regards,
Bin
- [PATCH v4 00/12] net: Pad short frames for network backends, Bin Meng, 2021/03/16
- [PATCH v4 01/12] net: eth: Add a helper to pad a short Ethernet frame, Bin Meng, 2021/03/16
- [PATCH v4 02/12] net: Add a 'do_not_pad" to NetClientState, Bin Meng, 2021/03/16
- [PATCH v4 03/12] net: Pad short frames to minimum size before sending from SLiRP/TAP, Bin Meng, 2021/03/16
- [PATCH v4 04/12] hw/net: virtio-net: Initialize nc->do_not_pad to true, Bin Meng, 2021/03/16
- [PATCH v4 05/12] hw/net: e1000: Remove the logic of padding short frames in the receive path, Bin Meng, 2021/03/16
- [PATCH v4 06/12] hw/net: vmxnet3: Remove the logic of padding short frames in the receive path, Bin Meng, 2021/03/16
- [PATCH v4 07/12] hw/net: i82596: Remove the logic of padding short frames in the receive path, Bin Meng, 2021/03/16
- [PATCH v4 08/12] hw/net: ne2000: Remove the logic of padding short frames in the receive path, Bin Meng, 2021/03/16
- [PATCH v4 09/12] hw/net: pcnet: Remove the logic of padding short frames in the receive path, Bin Meng, 2021/03/16
- [PATCH v4 10/12] hw/net: rtl8139: Remove the logic of padding short frames in the receive path, Bin Meng, 2021/03/16