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 <[email protected]> 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 > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
