|
@@ -3492,3 +3492,26 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
|
|
|
return true;
|
|
|
}
|
|
|
EXPORT_SYMBOL(skb_try_coalesce);
|
|
|
+
|
|
|
+/**
|
|
|
+ * skb_scrub_packet - scrub an skb before sending it to another netns
|
|
|
+ *
|
|
|
+ * @skb: buffer to clean
|
|
|
+ *
|
|
|
+ * skb_scrub_packet can be used to clean an skb before injecting it in
|
|
|
+ * another namespace. We have to clear all information in the skb that
|
|
|
+ * could impact namespace isolation.
|
|
|
+ */
|
|
|
+void skb_scrub_packet(struct sk_buff *skb)
|
|
|
+{
|
|
|
+ skb_orphan(skb);
|
|
|
+ skb->tstamp.tv64 = 0;
|
|
|
+ skb->pkt_type = PACKET_HOST;
|
|
|
+ skb->skb_iif = 0;
|
|
|
+ skb_dst_drop(skb);
|
|
|
+ skb->mark = 0;
|
|
|
+ secpath_reset(skb);
|
|
|
+ nf_reset(skb);
|
|
|
+ nf_reset_trace(skb);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(skb_scrub_packet);
|