mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ofpbuf: Abstract 'l2' pointer and document usage conventions.
Rename 'l2' to 'frame' and add new ofpbuf_set_frame() and ofpbuf_l2().
ofpbuf_set_frame() alse resets all the layer offsets. ofpbuf_l2()
returns NULL if the packet has no Ethernet header, as indicated either
by unset l3 offset or NULL frame pointer. Callers of ofpbuf_l2() are
supposed to check the return value, unless they can otherwise be sure
that the packet has a valid Ethernet header.
The recent commit 437d0d22
made some assumptions that were not valid
regarding the use of the 'l2' pointer in rconn module and by
compose_rarp(). This is now fixed as follows: rconn now relies on the
fact that once OpenFlow messages are given to rconn for transport, the
frame pointer is no longer needed to refer to the OpenFlow header; and
compose_rarp() now sets the frame pointer and offsets as expected.
In addition to storing network frames, ofpbufs are also used for
handling OpenFlow messages and action lists. lib/ofpbuf.h now has a
comment documenting the current usage conventions and invariants.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -371,10 +371,7 @@ flow_extract(struct ofpbuf *packet, const struct pkt_metadata *md,
|
||||
flow->pkt_mark = md->pkt_mark;
|
||||
}
|
||||
|
||||
packet->l2 = ofpbuf_data(&b);
|
||||
ofpbuf_set_l2_5(packet, NULL);
|
||||
ofpbuf_set_l3(packet, NULL);
|
||||
ofpbuf_set_l4(packet, NULL);
|
||||
ofpbuf_set_frame(packet, ofpbuf_data(packet));
|
||||
|
||||
if (ofpbuf_size(&b) < sizeof *eth) {
|
||||
return;
|
||||
@@ -1330,7 +1327,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
|
||||
/* eth_compose() sets l3 pointer and makes sure it is 32-bit aligned. */
|
||||
eth_compose(b, flow->dl_dst, flow->dl_src, ntohs(flow->dl_type), 0);
|
||||
if (flow->dl_type == htons(FLOW_DL_TYPE_NONE)) {
|
||||
struct eth_header *eth = b->l2;
|
||||
struct eth_header *eth = ofpbuf_l2(b);
|
||||
eth->eth_type = htons(ofpbuf_size(b));
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user