From: Jiri Benc <jbenc@redhat.com>
To: Yi Yang <yi.y.yang@intel.com>
Cc: netdev@vger.kernel.org, dev@openvswitch.org, e@erig.me,
pshelar@ovn.org, davem@davemloft.net
Subject: Re: [PATCH net-next v14] openvswitch: enable NSH support
Date: Tue, 31 Oct 2017 21:08:22 +0100 [thread overview]
Message-ID: <20171031210822.6901255a@redhat.com> (raw)
In-Reply-To: <1509326974-3750-1-git-send-email-yi.y.yang@intel.com>
On Mon, 30 Oct 2017 09:29:34 +0800, Yi Yang wrote:
> +static int set_nsh(struct sk_buff *skb, struct sw_flow_key *flow_key,
> + const struct nlattr *a)
> +{
> + struct nshhdr *nh;
> + size_t length;
> + int err;
> + u8 flags;
> + u8 ttl;
> + int i;
> +
> + struct ovs_key_nsh key;
> + struct ovs_key_nsh mask;
> +
> + err = nsh_key_from_nlattr(a, &key, &mask);
> + if (err)
> + return err;
> +
> + /* Make sure the NSH base header is there */
> + if (!pskb_may_pull(skb, NSH_BASE_HDR_LEN))
This should be skb_network_offset(skb) + NSH_BASE_HDR_LEN.
> +size_t ovs_nsh_key_attr_size(void)
> +{
> + /* Whenever adding new OVS_NSH_KEY_ FIELDS, we should consider
> + * updating this function.
> + */
> + return nla_total_size(NSH_BASE_HDR_LEN) /* OVS_NSH_KEY_ATTR_BASE */
> + /* OVS_NSH_KEY_ATTR_MD1 and OVS_NSH_KEY_ATTR_MD2 are
> + * mutually exclusive, so the bigger one can cover
> + * the small one.
> + *
> + * OVS_NSH_KEY_ATTR_MD2
> + */
A nit, not important but since you'll need to respin anyway: the last
line in the comment above seems to be a left over from some previous
version of the comment. This should be enough:
/* OVS_NSH_KEY_ATTR_MD1 and OVS_NSH_KEY_ATTR_MD2 are
* mutually exclusive, so the bigger one can cover
* the small one.
*/
Or maybe I misunderstood what you meant.
> +int nsh_hdr_from_nlattr(const struct nlattr *attr,
> + struct nshhdr *nh, size_t size)
> +{
> + struct nlattr *a;
> + int rem;
> + u8 flags = 0;
> + u8 ttl = 0;
> + int mdlen = 0;
> +
> + /* validate_nsh has check this, so we needn't do duplicate check here
> + */
> + nla_for_each_nested(a, attr, rem) {
> + int type = nla_type(a);
> +
> + switch (type) {
> + case OVS_NSH_KEY_ATTR_BASE: {
> + const struct ovs_nsh_key_base *base = nla_data(a);
> +
> + flags = base->flags;
> + ttl = base->ttl;
> + nh->np = base->np;
> + nh->mdtype = base->mdtype;
> + nh->path_hdr = base->path_hdr;
> + break;
> + }
> + case OVS_NSH_KEY_ATTR_MD1:
> + mdlen = nla_len(a);
> + memcpy(&nh->md1, nla_data(a), mdlen);
The check for 'size' disappeared from here somehow.
> + break;
> +
> + case OVS_NSH_KEY_ATTR_MD2:
> + mdlen = nla_len(a);
> + memcpy(&nh->md2, nla_data(a), mdlen);
And here.
Jiri
next prev parent reply other threads:[~2017-10-31 20:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-30 1:29 [PATCH net-next v14] openvswitch: enable NSH support Yi Yang
2017-10-31 19:57 ` Eric Garver
2017-10-31 20:02 ` Jiri Benc
2017-11-01 4:04 ` Yang, Yi
2017-10-31 20:08 ` Jiri Benc [this message]
2017-11-01 4:07 ` Yang, Yi
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=20171031210822.6901255a@redhat.com \
--to=jbenc@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=e@erig.me \
--cc=netdev@vger.kernel.org \
--cc=pshelar@ovn.org \
--cc=yi.y.yang@intel.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).