netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: amir@vadai.me
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, ogerlitz@mellanox.com,
	hadarh@mellanox.com
Subject: Re: [PATCH net-next 2/3] net/act_pedit: Support using offset relative to the conventional network headers
Date: Thu, 01 Dec 2016 14:41:14 -0500 (EST)	[thread overview]
Message-ID: <20161201.144114.648583754166260714.davem@davemloft.net> (raw)
In-Reply-To: <20161130090928.14816-3-amir@vadai.me>

From: Amir Vadai <amir@vadai.me>
Date: Wed, 30 Nov 2016 11:09:27 +0200

> @@ -119,18 +119,45 @@ static bool offset_valid(struct sk_buff *skb, int offset)
>  	return true;
>  }
>  
> +static int pedit_skb_hdr_offset(struct sk_buff *skb,
> +				enum pedit_header_type htype, int *hoffset)
> +{
> +	int ret = -1;
> +
> +	switch (htype) {
> +	case PEDIT_HDR_TYPE_ETH:
> +		if (skb_mac_header_was_set(skb)) {
> +			*hoffset = skb_mac_offset(skb);
> +			ret = 0;
> +		}
> +		break;
> +	case PEDIT_HDR_TYPE_RAW:
> +	case PEDIT_HDR_TYPE_IP4:
> +	case PEDIT_HDR_TYPE_IP6:
> +		*hoffset = skb_network_offset(skb);
> +		ret = 0;
> +		break;
> +	case PEDIT_HDR_TYPE_TCP:
> +	case PEDIT_HDR_TYPE_UDP:
> +		if (skb_transport_header_was_set(skb)) {
> +			*hoffset = skb_transport_offset(skb);
> +			ret = 0;
> +		}
> +		break;
> +	};
> +
> +	return ret;
> +}
> +

The only distinction between the cases is "L2", "L3", and "L4".

Therefore I don't see any reason to break it down into IP4 vs. IP6 vs.
RAW, for example.  They all map to the same thing.

So why not just have PEDIT_HDR_TYPE_L2, PEDIT_HDR_TYPE_L3, and
PEDIT_HDR_TYPE_L4?  It definitely seems more straightforward
and cleaner that way.

Thanks.

  reply	other threads:[~2016-12-01 19:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30  9:09 [PATCH net-next 0/3] net/sched: act_pedit: Support using offset relative to the conventional network headers Amir Vadai
2016-11-30  9:09 ` [PATCH net-next 1/3] net/skbuff: Introduce skb_mac_offset() Amir Vadai
2016-11-30  9:09 ` [PATCH net-next 2/3] net/act_pedit: Support using offset relative to the conventional network headers Amir Vadai
2016-12-01 19:41   ` David Miller [this message]
2016-12-02 10:40     ` Amir Vadai
2016-12-04 21:55       ` Or Gerlitz
2016-11-30  9:09 ` [PATCH net-next 3/3] net/act_pedit: Introduce 'add' operation Amir Vadai

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=20161201.144114.648583754166260714.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=amir@vadai.me \
    --cc=hadarh@mellanox.com \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.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).