The OVN test suite identified a bug in dp_packet_ol_send_prepare() where
a BFD packet flagged as double encapsulated would trigger a seg fault.
The problem surfaced because bfd_put_packet was reusing a packet
allocated on the stack that wasn't having its flags reset between calls.

This change will reset OL flags as well as the layer offsets in
data_clear(), which should fix this type of packet reuse issue in
general as long as data_clear() is called in between uses.

Fixes: 8b5fe2dc6080 ("userspace: Add Generic Segmentation Offloading.")
Reported-by: Dumitru Ceara <[email protected]>
Reported-at: https://issues.redhat.com/browse/FDP-300
Signed-off-by: Mike Pattrick <[email protected]>
---
 lib/dp-packet.h | 3 +++
 lib/packets.c   | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 939bec5c8..dceb701e8 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -207,6 +207,7 @@ void *dp_packet_resize_l2(struct dp_packet *, int 
increment);
 void *dp_packet_resize_l2_5(struct dp_packet *, int increment);
 static inline void *dp_packet_eth(const struct dp_packet *);
 static inline void dp_packet_reset_offsets(struct dp_packet *);
+static inline void dp_packet_reset_offload(struct dp_packet *);
 static inline uint16_t dp_packet_l2_pad_size(const struct dp_packet *);
 static inline void dp_packet_set_l2_pad_size(struct dp_packet *, uint16_t);
 static inline void *dp_packet_l2_5(const struct dp_packet *);
@@ -380,6 +381,8 @@ dp_packet_clear(struct dp_packet *b)
 {
     dp_packet_set_data(b, dp_packet_base(b));
     dp_packet_set_size(b, 0);
+    dp_packet_reset_offsets(b);
+    dp_packet_reset_offload(b);
 }
 
 /* Removes 'size' bytes from the head end of 'b', which must contain at least
diff --git a/lib/packets.c b/lib/packets.c
index f23d25420..36c6692e5 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -224,7 +224,6 @@ compose_rarp(struct dp_packet *b, const struct eth_addr 
eth_src)
     arp->ar_tha = eth_src;
     put_16aligned_be32(&arp->ar_tpa, htonl(0));
 
-    dp_packet_reset_offsets(b);
     dp_packet_set_l3(b, arp);
     b->packet_type = htonl(PT_ETH);
 }
@@ -1114,7 +1113,6 @@ eth_compose(struct dp_packet *b, const struct eth_addr 
eth_dst,
     eth->eth_type = htons(eth_type);
 
     b->packet_type = htonl(PT_ETH);
-    dp_packet_reset_offsets(b);
     dp_packet_set_l3(b, data);
 
     return data;
@@ -1747,7 +1745,6 @@ compose_arp__(struct dp_packet *b)
     arp->ar_hln = sizeof arp->ar_sha;
     arp->ar_pln = sizeof arp->ar_spa;
 
-    dp_packet_reset_offsets(b);
     dp_packet_set_l3(b, arp);
 
     b->packet_type = htonl(PT_ETH);
-- 
2.39.3

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to