lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b849f25-3e2e-0a9a-01c2-6f1fa483cd57@redhat.com>
Date:   Wed, 25 Jan 2023 11:12:26 +0100
From:   Jesper Dangaard Brouer <jbrouer@...hat.com>
To:     Lorenzo Bianconi <lorenzo@...nel.org>, bpf@...r.kernel.org
Cc:     brouer@...hat.com, netdev@...r.kernel.org, ast@...nel.org,
        daniel@...earbox.net, andrii@...nel.org, davem@...emloft.net,
        kuba@...nel.org, hawk@...nel.org, pabeni@...hat.com,
        edumazet@...gle.com, toke@...hat.com, memxor@...il.com,
        alardam@...il.com, saeedm@...dia.com, anthony.l.nguyen@...el.com,
        gospo@...adcom.com, vladimir.oltean@....com, nbd@....name,
        john@...ozen.org, leon@...nel.org, simon.horman@...igine.com,
        aelior@...vell.com, christophe.jaillet@...adoo.fr,
        ecree.xilinx@...il.com, mst@...hat.com, bjorn@...nel.org,
        magnus.karlsson@...el.com, maciej.fijalkowski@...el.com,
        intel-wired-lan@...ts.osuosl.org, lorenzo.bianconi@...hat.com,
        martin.lau@...ux.dev
Subject: Re: [PATCH v2 bpf-next 1/8] netdev-genl: create a simple family for
 netdev stuff


On 25/01/2023 01.33, Lorenzo Bianconi wrote:
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 90f2be194bc5..2cbe9a6ede76 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -47,6 +47,7 @@
>   #include <uapi/linux/netdevice.h>
>   #include <uapi/linux/if_bonding.h>
>   #include <uapi/linux/pkt_cls.h>
> +#include <uapi/linux/netdev.h>
>   #include <linux/hashtable.h>
>   #include <linux/rbtree.h>
>   #include <net/net_trackers.h>
> @@ -2055,6 +2056,7 @@ struct net_device {
>   
>   	/* Read-mostly cache-line for fast-path access */
>   	unsigned int		flags;
> +	xdp_features_t		xdp_features;

Nice you found a 4 bytes hole to place the u32 xdp_features member in
and in a "Read-mostly cache-line for fast-path access" that is good :-)
(Added my pahole output for reference below)

Acked-by: Jesper Dangaard Brouer <brouer@...hat.com>

>   	unsigned long long	priv_flags;
>   	const struct net_device_ops *netdev_ops;
>   	const struct xdp_metadata_ops *xdp_metadata_ops;
> @@ -2839,6 +2841,7 @@ enum netdev_cmd {
>   	NETDEV_OFFLOAD_XSTATS_DISABLE,
>   	NETDEV_OFFLOAD_XSTATS_REPORT_USED,
>   	NETDEV_OFFLOAD_XSTATS_REPORT_DELTA,
> +	NETDEV_XDP_FEAT_CHANGE,
>   };
>   const char *netdev_cmd_to_name(enum netdev_cmd cmd);
>   
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 91292aa13bc0..8d1c86914f4c 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -7,6 +7,7 @@
>   #define __LINUX_NET_XDP_H__
>   
>   #include <linux/skbuff.h> /* skb_shared_info */
> +#include <uapi/linux/netdev.h>
>   
>   /**
>    * DOC: XDP RX-queue information
> @@ -43,6 +44,8 @@ enum xdp_mem_type {
>   	MEM_TYPE_MAX,
>   };
>   
> +typedef u32 xdp_features_t;
> +
>   /* XDP flags for ndo_xdp_xmit */
>   #define XDP_XMIT_FLUSH		(1U << 0)	/* doorbell signal consumer */
>   #define XDP_XMIT_FLAGS_MASK	XDP_XMIT_FLUSH


--Jesper

On 64 bit arch partial output from:
   pahole -C net_device net/core/skbuff.o

struct net_device {
         char                       name[16];             /*     0    16 */
         struct netdev_name_node *  name_node;            /*    16     8 */
         struct dev_ifalias *       ifalias;              /*    24     8 */
         long unsigned int          mem_end;              /*    32     8 */
         long unsigned int          mem_start;            /*    40     8 */
         long unsigned int          base_addr;            /*    48     8 */
         long unsigned int          state;                /*    56     8 */
         /* --- cacheline 1 boundary (64 bytes) --- */
         struct list_head           dev_list;             /*    64    16 */
         struct list_head           napi_list;            /*    80    16 */
         struct list_head           unreg_list;           /*    96    16 */
         struct list_head           close_list;           /*   112    16 */
         /* --- cacheline 2 boundary (128 bytes) --- */
         struct list_head           ptype_all;            /*   128    16 */
         struct list_head           ptype_specific;       /*   144    16 */
         struct {
                 struct list_head   upper;                /*   160    16 */
                 struct list_head   lower;                /*   176    16 */
         } adj_list;                                      /*   160    32 */
         /* --- cacheline 3 boundary (192 bytes) --- */
         unsigned int               flags;                /*   192     4 */

         /* XXX 4 bytes hole, try to pack */

         long long unsigned int     priv_flags;           /*   200     8 */
         const struct net_device_ops  * netdev_ops;       /*   208     8 */
         const struct xdp_metadata_ops  * xdp_metadata_ops; /*   216 
8 */
         int                        ifindex;              /*   224     4 */
         short unsigned int         gflags;               /*   228     2 */
         short unsigned int         hard_header_len;      /*   230     2 */
         unsigned int               mtu;                  /*   232     4 */
         short unsigned int         needed_headroom;      /*   236     2 */
         short unsigned int         needed_tailroom;      /*   238     2 */
         netdev_features_t          features;             /*   240     8 */
         netdev_features_t          hw_features;          /*   248     8 */
         /* --- cacheline 4 boundary (256 bytes) --- */
         netdev_features_t          wanted_features;      /*   256     8 */
         netdev_features_t          vlan_features;        /*   264     8 */
         netdev_features_t          hw_enc_features;      /*   272     8 */
         netdev_features_t          mpls_features;        /*   280     8 */
         netdev_features_t          gso_partial_features; /*   288     8 */
         unsigned int               min_mtu;              /*   296     4 */
         unsigned int               max_mtu;              /*   300     4 */
         short unsigned int         type;                 /*   304     2 */
         unsigned char              min_header_len;       /*   306     1 */
         unsigned char              name_assign_type;     /*   307     1 */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ