[ovs-git] [openvswitch/ovs] d274cf: datapath: meter: Use struct_size() in kzalloc()

Justin Pettit noreply at github.com
Thu Sep 5 23:22:47 UTC 2019


  Branch: refs/heads/branch-2.11
  Home:   https://github.com/openvswitch/ovs
  Commit: d274cf722937fa3ab6d51f4dfb64f5585230889a
      https://github.com/openvswitch/ovs/commit/d274cf722937fa3ab6d51f4dfb64f5585230889a
  Author: Gustavo A. R. Silva <gustavo at embeddedor.com>
  Date:   2019-09-05 (Thu, 05 Sep 2019)

  Changed paths:
    M acinclude.m4
    M datapath/linux/Modules.mk
    A datapath/linux/compat/include/linux/mm.h
    A datapath/linux/compat/include/linux/overflow.h
    M datapath/meter.c

  Log Message:
  -----------
  datapath: meter: Use struct_size() in kzalloc()

Upstream commit:
    commit c5c3899de09e307e3a0999ab8d620ab0ede05aa1
    Author: Gustavo A. R. Silva <gustavo at embeddedor.com>
    Date:   Tue Jan 15 15:19:17 2019 -0600

    openvswitch: meter: Use struct_size() in kzalloc()

    One of the more common cases of allocation size calculations is finding the
    size of a structure that has a zero-sized array at the end, along with
    memory for some number of elements for that array. For example:

    struct foo {
        int stuff;
        struct boo entry[];
    };

    instance = kzalloc(sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);

    Instead of leaving these open-coded and prone to type mistakes, we can now
    use the new struct_size() helper:

    instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);

    This code was detected with the help of Coccinelle.

    Signed-off-by: Gustavo A. R. Silva <gustavo at embeddedor.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>

Use of struct_size() needed some compat layer adjustments to make use
of this new macro.  This patch pulls in some of the needed support
from the linux mm.h and overflow.h header files.  This new header
file support is also necessary for the following patch that converts
to use of kvmalloc().

Cc: Gustavo A. R. Silva <gustavo at embeddedor.com>
Signed-off-by: Greg Rose <gvrose8192 at gmail.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: a9d747a904e7796b9e058b626a428e7f96983928
      https://github.com/openvswitch/ovs/commit/a9d747a904e7796b9e058b626a428e7f96983928
  Author: Yifeng Sun <pkusunyifeng at gmail.com>
  Date:   2019-09-05 (Thu, 05 Sep 2019)

  Changed paths:
    M .travis.yml
    M acinclude.m4
    M datapath/linux/compat/include/linux/overflow.h
    M datapath/meter.c

  Log Message:
  -----------
  datapath: Fix compiling error for 4.14.111+ kernel

Acked-by: Yi-Hung Wei <yihung.wei at gmail.com>
Tested-by: Greg Rose <gvrose8192 at gmail.com>
Reviewed-by: Greg Rose <gvrose8192 at gmail.com>
Fixes: f72469405eec9 ("datapath: meter: Use struct_size() in kzalloc()")
Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: c6b161cd449e9d7d4ffba8dbfa1d438904776f41
      https://github.com/openvswitch/ovs/commit/c6b161cd449e9d7d4ffba8dbfa1d438904776f41
  Author: Yifeng Sun <pkusunyifeng at gmail.com>
  Date:   2019-09-05 (Thu, 05 Sep 2019)

  Changed paths:
    M acinclude.m4
    M datapath/linux/compat/nf_conntrack_proto.c

  Log Message:
  -----------
  datapath: Handle removal of nf_conntrack_l3proto.h

Upstream kernel commit a0ae2562 ("netfilter: conntrack: remove l3proto
abstraction") removed header file net/netfilter/nf_conntrack_l3proto.h.
This patch detects it and fixes compilation errors of OVS on 4.19+ kernels.

Tested-by: Greg Rose <gvrose8192 at gmail.com>
Reviewed-by: Greg Rose <gvrose8192 at gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei at gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: e9803904faec184151795454ffe3fd8982aae5bc
      https://github.com/openvswitch/ovs/commit/e9803904faec184151795454ffe3fd8982aae5bc
  Author: Florian Westphal <fw at strlen.de>
  Date:   2019-09-05 (Thu, 05 Sep 2019)

  Changed paths:
    M acinclude.m4
    M datapath/conntrack.c
    M datapath/linux/Modules.mk
    A datapath/linux/compat/include/linux/netfilter.h
    M datapath/linux/compat/include/net/netfilter/nf_conntrack_core.h

  Log Message:
  -----------
  datapath: Pass nf_hook_state to nf_conntrack_in()

Upstream Commit:
    commit 93e66024b0249cec81e91328c55a754efd3192e0
    Author: Florian Westphal <fw at strlen.de>
    Date:   Wed Sep 12 15:19:07 2018 +0200

    netfilter: conntrack: pass nf_hook_state to packet and error handlers

    nf_hook_state contains all the hook meta-information: netns, protocol family,
    hook location, and so on.

    Instead of only passing selected information, pass a pointer to entire
    structure.

    This will allow to merge the error and the packet handlers and remove
    the ->new() function in followup patches.

    Signed-off-by: Florian Westphal <fw at strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

This patch backports the above upstream patch to OVS and fixes compiling
errors on RHEL kernels.

Cc: Florian Westphal <fw at strlen.de>
Tested-by: Greg Rose <gvrose8192 at gmail.com>
Reviewed-by: Greg Rose <gvrose8192 at gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei at gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


  Commit: ca633c77941cfdc2ac45580eaf504856bf7b80a8
      https://github.com/openvswitch/ovs/commit/ca633c77941cfdc2ac45580eaf504856bf7b80a8
  Author: Florian Westphal <fw at strlen.de>
  Date:   2019-09-05 (Thu, 05 Sep 2019)

  Changed paths:
    M acinclude.m4
    M datapath/conntrack.c
    M datapath/linux/Modules.mk
    A datapath/linux/compat/include/net/ipv6_frag.h

  Log Message:
  -----------
  datapath: Use new header file net/ipv6_frag.h

Upstream commit:
    commit 70b095c84326640eeacfd69a411db8fc36e8ab1a
    Author: Florian Westphal <fw at strlen.de>
    Date:   Sat Jul 14 01:14:01 2018 +0200

    ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module

    IPV6=m
    DEFRAG_IPV6=m
    CONNTRACK=y yields:

    net/netfilter/nf_conntrack_proto.o: In function `nf_ct_netns_do_get':
    net/netfilter/nf_conntrack_proto.c:802: undefined reference to `nf_defrag_ipv6_enable'
    net/netfilter/nf_conntrack_proto.o:(.rodata+0x640): undefined reference to `nf_conntrack_l4proto_icmpv6'

    Setting DEFRAG_IPV6=y causes undefined references to ip6_rhash_params
    ip6_frag_init and ip6_expire_frag_queue so it would be needed to force
    IPV6=y too.

    This patch gets rid of the 'followup linker error' by removing
    the dependency of ipv6.ko symbols from netfilter ipv6 defrag.

    Shared code is placed into a header, then used from both.

    Signed-off-by: Florian Westphal <fw at strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

This patch backports the above upstream patch to OVS.

Cc: Florian Westphal <fw at strlen.de>
Tested-by: Greg Rose <gvrose8192 at gmail.com>
Reviewed-by: Greg Rose <gvrose8192 at gmail.com>
Acked-by: Yi-Hung Wei <yihung.wei at gmail.com>
Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
Signed-off-by: Ben Pfaff <blp at ovn.org>


Compare: https://github.com/openvswitch/ovs/compare/1516d0997428...ca633c77941c


More information about the git mailing list