netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
	netdev@vger.kernel.org, kuba@kernel.org, edumazet@google.com,
	fw@strlen.de
Subject: Re: [PATCH net 4/6] netfilter: nft_payload: skbuff vlan metadata mangle support
Date: Thu, 23 May 2024 17:12:41 +0200	[thread overview]
Message-ID: <Zk9c6TfO6_BRvbkN@calendula> (raw)
In-Reply-To: <e20cde161e014616d0b4969f2bec22cd80ca2c5a.camel@redhat.com>

On Thu, May 23, 2024 at 11:26:45AM +0200, Paolo Abeni wrote:
> On Thu, 2024-05-23 at 01:13 +0200, Pablo Neira Ayuso wrote:
> > @@ -801,21 +801,79 @@ struct nft_payload_set {
> >  	u8			csum_flags;
> >  };
> >  
> > +/* This is not struct vlan_hdr. */
> > +struct nft_payload_vlan_hdr {
> > +        __be16          h_vlan_proto;
> > +        __be16          h_vlan_TCI;
> > +};
> > +
> > +static bool
> > +nft_payload_set_vlan(const u32 *src, struct sk_buff *skb, u8 offset, u8 len,
> > +		     int *vlan_hlen)
> > +{
> > +	struct nft_payload_vlan_hdr *vlanh;
> > +	__be16 vlan_proto;
> > +	__be16 vlan_tci;
> > +
> > +	if (offset >= offsetof(struct vlan_ethhdr, h_vlan_encapsulated_proto)) {
> > +		*vlan_hlen = VLAN_HLEN;
> > +		return true;
> > +	}
> > +
> > +	switch (offset) {
> > +	case offsetof(struct vlan_ethhdr, h_vlan_proto):
> > +		if (len == 2) {
> > +			vlan_proto = nft_reg_load16(src);
> 
> I'm sorry but the above introduces build warning due to endianess
> mismatch (host -> be)
> 
> > +			skb->vlan_proto = vlan_proto;
> > +		} else if (len == 4) {
> > +			vlanh = (struct nft_payload_vlan_hdr *)src;
> > +			__vlan_hwaccel_put_tag(skb, vlanh->h_vlan_proto,
> > +					       ntohs(vlanh->h_vlan_TCI));
> > +		} else {
> > +			return false;
> > +		}
> > +		break;
> > +	case offsetof(struct vlan_ethhdr, h_vlan_TCI):
> > +		if (len != 2)
> > +			return false;
> > +
> > +		vlan_tci = ntohs(nft_reg_load16(src));
> 
> Similar things here htons() expect a be short int and is receiving a
> u16, vlan_tci is 'be' and the assigned data uses host endianess.
> 
> 
> Could you please address the above?

Sure, I will post v2.

  reply	other threads:[~2024-05-23 15:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22 23:13 [PATCH net 0/6] Netfilter fixes for net Pablo Neira Ayuso
2024-05-22 23:13 ` [PATCH net 1/6] netfilter: nfnetlink_queue: acquire rcu_read_lock() in instance_destroy_rcu() Pablo Neira Ayuso
2024-05-22 23:13 ` [PATCH net 2/6] netfilter: ipset: Add list flush to cancel_gc Pablo Neira Ayuso
2024-05-22 23:13 ` [PATCH net 3/6] netfilter: nft_payload: restore vlan q-in-q match support Pablo Neira Ayuso
2024-05-22 23:13 ` [PATCH net 4/6] netfilter: nft_payload: skbuff vlan metadata mangle support Pablo Neira Ayuso
2024-05-23  9:26   ` Paolo Abeni
2024-05-23 15:12     ` Pablo Neira Ayuso [this message]
2024-05-22 23:13 ` [PATCH net 5/6] netfilter: tproxy: bail out if IP has been disabled on the device Pablo Neira Ayuso
2024-05-22 23:13 ` [PATCH net 6/6] netfilter: nft_fib: allow from forward/input without iif selector Pablo Neira Ayuso
  -- strict thread matches above, loose matches on Subject: below --
2024-05-23 16:20 [PATCH net 0/6,v2] Netfilter fixes for net Pablo Neira Ayuso
2024-05-23 16:20 ` [PATCH net 4/6] netfilter: nft_payload: skbuff vlan metadata mangle support Pablo Neira Ayuso
2024-05-28 22:55 [PATCH net 0/6,v3] Netfilter fixes for net Pablo Neira Ayuso
2024-05-28 22:55 ` [PATCH net 4/6] netfilter: nft_payload: skbuff vlan metadata mangle support Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zk9c6TfO6_BRvbkN@calendula \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).