@@ -3524,21 +3524,58 @@ static inline void skb_frag_off_copy(skb_frag_t *fragto,
35243524 fragto -> offset = fragfrom -> offset ;
35253525}
35263526
3527+ /* Return: true if the skb_frag contains a net_iov. */
3528+ static inline bool skb_frag_is_net_iov (const skb_frag_t * frag )
3529+ {
3530+ return netmem_is_net_iov (frag -> netmem );
3531+ }
3532+
3533+ /**
3534+ * skb_frag_net_iov - retrieve the net_iov referred to by fragment
3535+ * @frag: the fragment
3536+ *
3537+ * Return: the &struct net_iov associated with @frag. Returns NULL if this
3538+ * frag has no associated net_iov.
3539+ */
3540+ static inline struct net_iov * skb_frag_net_iov (const skb_frag_t * frag )
3541+ {
3542+ if (!skb_frag_is_net_iov (frag ))
3543+ return NULL ;
3544+
3545+ return netmem_to_net_iov (frag -> netmem );
3546+ }
3547+
35273548/**
35283549 * skb_frag_page - retrieve the page referred to by a paged fragment
35293550 * @frag: the paged fragment
35303551 *
3531- * Returns the &struct page associated with @frag.
3552+ * Return: the &struct page associated with @frag. Returns NULL if this frag
3553+ * has no associated page.
35323554 */
35333555static inline struct page * skb_frag_page (const skb_frag_t * frag )
35343556{
3557+ if (skb_frag_is_net_iov (frag ))
3558+ return NULL ;
3559+
35353560 return netmem_to_page (frag -> netmem );
35363561}
35373562
3563+ /**
3564+ * skb_frag_netmem - retrieve the netmem referred to by a fragment
3565+ * @frag: the fragment
3566+ *
3567+ * Return: the &netmem_ref associated with @frag.
3568+ */
3569+ static inline netmem_ref skb_frag_netmem (const skb_frag_t * frag )
3570+ {
3571+ return frag -> netmem ;
3572+ }
3573+
35383574int skb_pp_cow_data (struct page_pool * pool , struct sk_buff * * pskb ,
35393575 unsigned int headroom );
35403576int skb_cow_data_for_xdp (struct page_pool * pool , struct sk_buff * * pskb ,
35413577 struct bpf_prog * prog );
3578+
35423579/**
35433580 * skb_frag_address - gets the address of the data contained in a paged fragment
35443581 * @frag: the paged fragment buffer
@@ -3548,6 +3585,9 @@ int skb_cow_data_for_xdp(struct page_pool *pool, struct sk_buff **pskb,
35483585 */
35493586static inline void * skb_frag_address (const skb_frag_t * frag )
35503587{
3588+ if (!skb_frag_page (frag ))
3589+ return NULL ;
3590+
35513591 return page_address (skb_frag_page (frag )) + skb_frag_off (frag );
35523592}
35533593
0 commit comments