[ovs-dev] [bondlib 04/19] packets: Reserve headroom for VLAN header in eth_compose(), snap_compose().

Ethan Jackson ethan at nicira.com
Mon Mar 28 20:43:41 UTC 2011


Looks Good to me.

It might be worth commenting why we are allocating and reserving
VLAN_HEADER_LEN extra bytes.  That may confuse a future reader.

Ethan

On Fri, Mar 25, 2011 at 10:35 AM, Ben Pfaff <blp at nicira.com> wrote:
> This allows callers to add a VLAN header to the composed packet and send
> it out on a VLAN without copying the whole payload.
> ---
>  lib/packets.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/lib/packets.c b/lib/packets.c
> index 4c6cc48..25c5dda 100644
> --- a/lib/packets.c
> +++ b/lib/packets.c
> @@ -236,7 +236,8 @@ eth_compose(struct ofpbuf *b, const uint8_t eth_dst[ETH_ADDR_LEN],
>
>     ofpbuf_clear(b);
>
> -    ofpbuf_prealloc_tailroom(b, ETH_HEADER_LEN + size);
> +    ofpbuf_prealloc_tailroom(b, ETH_HEADER_LEN + VLAN_HEADER_LEN + size);
> +    ofpbuf_reserve(b, VLAN_HEADER_LEN);
>     eth = ofpbuf_put_uninit(b, ETH_HEADER_LEN);
>     data = ofpbuf_put_uninit(b, size);
>
> @@ -263,7 +264,9 @@ snap_compose(struct ofpbuf *b, const uint8_t eth_dst[ETH_ADDR_LEN],
>     /* Compose basic packet structure.  (We need the payload size to stick into
>      * the 802.2 header.) */
>     ofpbuf_clear(b);
> -    ofpbuf_prealloc_tailroom(b, ETH_HEADER_LEN + LLC_SNAP_HEADER_LEN + size);
> +    ofpbuf_prealloc_tailroom(b, ETH_HEADER_LEN + VLAN_HEADER_LEN
> +                             + LLC_SNAP_HEADER_LEN + size);
> +    ofpbuf_reserve(b, VLAN_HEADER_LEN);
>     eth = ofpbuf_put_zeros(b, ETH_HEADER_LEN);
>     llc_snap = ofpbuf_put_zeros(b, LLC_SNAP_HEADER_LEN);
>     payload = ofpbuf_put_uninit(b, size);
> --
> 1.7.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list