All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 00/3] Introduce MACsec offload SKB extension
@ 2022-06-13 11:19 Lior Nahmanson
  2022-06-13 11:19 ` [PATCH net-next v3 1/3] net/macsec: Add MACsec skb extension Tx Data path support Lior Nahmanson
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Lior Nahmanson @ 2022-06-13 11:19 UTC (permalink / raw)
  To: edumazet, kuba, pabeni; +Cc: davem, netdev, Lior Nahmanson

This patchset introduces MACsec SKB extension to lay the ground
for MACsec HW offload.

MACsec is an IEEE standard (IEEE 802.1AE) for MAC security.
It defines a way to establish a protocol independent connection
between two hosts with data confidentiality, authenticity and/or
integrity, using GCM-AES. MACsec operates on the Ethernet layer and
as such is a layer 2 protocol, which means it’s designed to secure
traffic within a layer 2 network, including DHCP or ARP requests.

Linux has a software implementation of the MACsec standard and
HW offloading support.
The offloading is re-using the logic, netlink API and data
structures of the existing MACsec software implementation.

For Tx:
In the current MACsec offload implementation, MACsec interfaces are
sharing the same MAC address of their parent interface by default.
Therefore, HW can't distinguish if a packet was sent from MACsec
interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in
case there are multiple MACsec interface with the same MAC address.

Used SKB extension, so SW can mark if a packet is needed to be offloaded
and use the SCI, which is unique value for each MACsec interface,
to notify the HW from which MACsec interface the packet is sent.

For Rx:
Like in the Tx changes, packet that don't have SecTAG
header aren't necessary been offloaded by the HW.
Therefore, the MACsec driver needs to distinguish if the packet
was offloaded or not and handle accordingly.
Moreover, if there are more than one MACsec device with the same MAC
address as in the packet's destination MAC, the packet will forward only
to this device and only to the desired one.

Used SKB extension and marking it by the HW if the packet was offloaded
and to which MACsec offload device it belongs according to the packet's
SCI.

1) patch 0001-0002, Add support to SKB extension in MACsec code:
net/macsec: Add MACsec skb extension Tx Data path support
net/macsec: Add MACsec skb extension Rx Data path support

2) patch 0003, Move some MACsec driver code for sharing with various
drivers that implements offload:
net/macsec: Move some code for sharing with various drivers that
implements offload

Follow-up patchset for Nvidia MACsec HW offload will be submitted
later on.

 drivers/net/Kconfig    |  1 +
 drivers/net/macsec.c   | 45 ++++++++++++++++--------------------------
 include/linux/skbuff.h |  3 +++
 include/net/macsec.h   | 27 +++++++++++++++++++++++++
 net/core/gro.c         | 16 +++++++++++++++
 net/core/skbuff.c      |  7 +++++++
 6 files changed, 71 insertions(+), 28 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH net-next v3 2/3] net/macsec: Add MACsec skb extension Rx Data path support
@ 2022-06-15 13:16 kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2022-06-15 13:16 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 14917 bytes --]

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: net/core/gro.c:417:77: warning: dereference of NULL 'macsec_p_ext' [CWE-476] [-Wanalyzer-null-dereference]"
:::::: 

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220613111942.12726-3-liorna@nvidia.com>
References: <20220613111942.12726-3-liorna@nvidia.com>
TO: Lior Nahmanson <liorna@nvidia.com>
TO: edumazet(a)google.com
TO: kuba(a)kernel.org
TO: pabeni(a)redhat.com
CC: davem(a)davemloft.net
CC: netdev(a)vger.kernel.org
CC: Lior Nahmanson <liorna@nvidia.com>
CC: Raed Salem <raeds@nvidia.com>
CC: Jiri Pirko <jiri@nvidia.com>
CC: "Ben Ben-Ishay" <benishay@nvidia.com>

Hi Lior,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Lior-Nahmanson/Introduce-MACsec-offload-SKB-extension/20220613-211703
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 5f30671d8dc6b7a489435ce8c40a2036e3c16d04
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: x86_64-randconfig-c001-20220613 (https://download.01.org/0day-ci/archive/20220615/202206152156.8ckKlv4A-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/9ee59a567b790747e39e7cdd959991b4d994fc52
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Lior-Nahmanson/Introduce-MACsec-offload-SKB-extension/20220613-211703
        git checkout 9ee59a567b790747e39e7cdd959991b4d994fc52
        # save the config file
         ARCH=x86_64 KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>


gcc-analyzer warnings: (new ones prefixed by >>)
              |  487 | static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
              |      |                        ^~~~~~~~~~~~~~~
              |      |                        |
              |      |                        (12) entry to 'dev_gro_receive'
              |
            'dev_gro_receive': event 13
              |
              |include/linux/netdevice.h:2340:12:
              | 2340 |         if (!(dev->features & NETIF_F_GRO) || dev->xdp_prog)
              |      |            ^
              |      |            |
              |      |            (13) following 'false' branch...
              |
            'dev_gro_receive': event 14
              |
              |net/core/gro.c:502:26:
              |  502 |         gro_list_prepare(&gro_list->list, skb);
              |      |                          ^~~~~~~~~~~~~~~
              |      |                          |
              |      |                          (14) ...to here
              |
            'dev_gro_receive': event 15
              |
              |include/linux/rculist.h:392:30:
              |  392 |                 &pos->member != (head);                                 \
              |      |                 ~~~~~~~~~~~~~^~~~~~~~~
              |      |                              |
              |      |                              (15) following 'true' branch...
   net/core/gro.c:505:9: note: in expansion of macro 'list_for_each_entry_rcu'
              |  505 |         list_for_each_entry_rcu(ptype, head, list) {
              |      |         ^~~~~~~~~~~~~~~~~~~~~~~
              |
            'dev_gro_receive': events 16-19
              |
              |  506 |                 if (ptype->type != type || !ptype->callbacks.gro_receive)
              |      |                     ~~~~~^~~~~~
              |      |                          |
              |      |                          (16) ...to here
              |......
              |  536 |         if (&ptype->list == head)
              |      |            ~              
              |      |            |
              |      |            (17) following 'false' branch...
              |......
              |  539 |         if (PTR_ERR(pp) == -EINPROGRESS) {
              |      |            ~              
              |      |            |
              |      |            (18) ...to here
              |      |            (19) following 'false' branch (when 'pp != 18446744073709551501')...
              |
            'dev_gro_receive': events 20-23
              |
              |  544 |         same_flow = NAPI_GRO_CB(skb)->same_flow;
              |......
              |  547 |         if (pp) {
              |      |            ~                         
              |      |            |
              |      |            (21) following 'false' branch (when 'pp' is NULL)...
              |......
              |  553 |         if (same_flow)
              |      |            ~                         
              |      |            |
              |      |            (22) ...to here
              |      |            (23) following 'false' branch...
              |
            'dev_gro_receive': events 24-25
              |
              |  556 |         if (NAPI_GRO_CB(skb)->flush)
              |      |            ~                 
              |      |            |
              |      |            (25) following 'false' branch...
              |
            'dev_gro_receive': event 26
              |
              |  559 |         if (unlikely(gro_list->count >= MAX_GRO_SKBS))
              |      |                      ~~~~~~~~^~~~~~~
              |      |                              |
              |      |                              (26) ...to here
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
              |   78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
              |      |                                             ^
              |
            'dev_gro_receive': event 27
              |
              |net/core/gro.c:566:32:
              |  566 |         NAPI_GRO_CB(skb)->last = skb;
              |
            'dev_gro_receive': event 28
              |
              |  566 |         NAPI_GRO_CB(skb)->last = skb;
              |
            'dev_gro_receive': event 29
              |
              |include/net/gro.h:128:19:
              |  128 |         return skb->len - NAPI_GRO_CB(skb)->data_offset;
              |      |                ~~~^~~~~
              |      |                   |
              |      |                   (29) dereference of NULL 'skb'
              |
   include/linux/skbuff.h: In function 'gro_list_prepare':
>> net/core/gro.c:417:77: warning: dereference of NULL 'macsec_p_ext' [CWE-476] [-Wanalyzer-null-dereference]
     417 |                                 diffs |= (__force unsigned long)macsec_p_ext->sci ^
         |                                                                 ~~~~~~~~~~~~^~~~~
     'napi_gro_frags': events 1-2
       |
       |  773 | gro_result_t napi_gro_frags(struct napi_struct *napi)
       |      |              ^~~~~~~~~~~~~~
       |      |              |
       |      |              (1) entry to 'napi_gro_frags'
       |......
       |  776 |         struct sk_buff *skb = napi_frags_skb(napi);
       |      |                               ~~~~~~~~~~~~~~~~~~~~
       |      |                               |
       |      |                               (2) calling 'napi_frags_skb' from 'napi_gro_frags'
       |
       +--> 'napi_frags_skb': events 3-6
              |
              |  736 | static struct sk_buff *napi_frags_skb(struct napi_struct *napi)
              |      |                        ^~~~~~~~~~~~~~
              |      |                        |
              |      |                        (3) entry to 'napi_frags_skb'
              |......
              |  747 |         if (unlikely(skb_gro_header_hard(skb, hlen))) {
              |      |            ~            
              |      |            |
              |      |            (4) following 'true' branch...
              |  748 |                 eth = skb_gro_header_slow(skb, hlen, 0);
              |      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              |      |                       |
              |      |                       (5) ...to here
              |  749 |                 if (unlikely(!eth)) {
              |      |                    ~    
              |      |                    |
              |      |                    (6) following 'true' branch...
              |
            'napi_frags_skb': event 7
              |
              |include/linux/net.h:265:13:
              |  265 |         if (net_ratelimit())                                    \
              |      |             ^~~~~~~~~~~~~~~
              |      |             |
              |      |             (7) ...to here
   include/linux/net.h:280:9: note: in expansion of macro 'net_ratelimited_function'
              |  280 |         net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
              |      |         ^~~~~~~~~~~~~~~~~~~~~~~~
   net/core/gro.c:750:25: note: in expansion of macro 'net_warn_ratelimited'
              |  750 |                         net_warn_ratelimited("%s: dropping impossible skb from %s\n",
              |      |                         ^~~~~~~~~~~~~~~~~~~~
              |
       <------+
       |
     'napi_gro_frags': events 8-9
       |
       |  776 |         struct sk_buff *skb = napi_frags_skb(napi);
       |      |                               ^~~~~~~~~~~~~~~~~~~~
       |      |                               |
       |      |                               (8) returning to 'napi_gro_frags' from 'napi_frags_skb'
       |......
       |  780 |         ret = napi_frags_finish(napi, skb, dev_gro_receive(napi, skb));
       |      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |               |
       |      |               (9) calling 'dev_gro_receive' from 'napi_gro_frags'
       |
       +--> 'dev_gro_receive': event 10
              |
              |  487 | static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
              |      |                        ^~~~~~~~~~~~~~~
              |      |                        |
              |      |                        (10) entry to 'dev_gro_receive'
              |
            'dev_gro_receive': event 11
              |
              |include/linux/netdevice.h:2340:12:
              | 2340 |         if (!(dev->features & NETIF_F_GRO) || dev->xdp_prog)
              |      |            ^
              |      |            |
              |      |            (11) following 'false' branch...
              |
            'dev_gro_receive': events 12-13
              |
              |net/core/gro.c:502:26:
              |  502 |         gro_list_prepare(&gro_list->list, skb);
              |      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
              |      |         |                |
              |      |         |                (12) ...to here
              |      |         (13) calling 'gro_list_prepare' from 'dev_gro_receive'
              |
              +--> 'gro_list_prepare': event 14
                     |
                     |  354 | static void gro_list_prepare(const struct list_head *head,
                     |      |             ^~~~~~~~~~~~~~~~
                     |      |             |
                     |      |             (14) entry to 'gro_list_prepare'
                     |
                   'gro_list_prepare': event 15
                     |
                     |include/linux/list.h:675:14:
                     |  675 |              !list_entry_is_head(pos, head, member);                    \
                     |      |              ^
                     |      |              |
                     |      |              (15) following 'true' branch...

vim +/macsec_p_ext +417 net/core/gro.c

587652bbdd06ab Eric Dumazet   2021-11-15  398  
587652bbdd06ab Eric Dumazet   2021-11-15  399  			diffs |= p->sk != skb->sk;
587652bbdd06ab Eric Dumazet   2021-11-15  400  			diffs |= skb_metadata_dst_cmp(p, skb);
587652bbdd06ab Eric Dumazet   2021-11-15  401  			diffs |= skb_get_nfct(p) ^ skb_get_nfct(skb);
587652bbdd06ab Eric Dumazet   2021-11-15  402  
587652bbdd06ab Eric Dumazet   2021-11-15  403  #if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
587652bbdd06ab Eric Dumazet   2021-11-15  404  			skb_ext = skb_ext_find(skb, TC_SKB_EXT);
587652bbdd06ab Eric Dumazet   2021-11-15  405  			p_ext = skb_ext_find(p, TC_SKB_EXT);
587652bbdd06ab Eric Dumazet   2021-11-15  406  
587652bbdd06ab Eric Dumazet   2021-11-15  407  			diffs |= (!!p_ext) ^ (!!skb_ext);
587652bbdd06ab Eric Dumazet   2021-11-15  408  			if (!diffs && unlikely(skb_ext))
587652bbdd06ab Eric Dumazet   2021-11-15  409  				diffs |= p_ext->chain ^ skb_ext->chain;
9ee59a567b7907 Lior Nahmanson 2022-06-13  410  #endif
9ee59a567b7907 Lior Nahmanson 2022-06-13  411  #if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_MACSEC)
9ee59a567b7907 Lior Nahmanson 2022-06-13  412  			macsec_skb_ext = skb_ext_find(skb, SKB_EXT_MACSEC);
9ee59a567b7907 Lior Nahmanson 2022-06-13  413  			macsec_p_ext = skb_ext_find(p, SKB_EXT_MACSEC);
9ee59a567b7907 Lior Nahmanson 2022-06-13  414  
9ee59a567b7907 Lior Nahmanson 2022-06-13  415  			diffs |= (!!macsec_p_ext) ^ (!!macsec_skb_ext);
9ee59a567b7907 Lior Nahmanson 2022-06-13  416  			if (!diffs && unlikely(macsec_skb_ext)) {
9ee59a567b7907 Lior Nahmanson 2022-06-13 @417  				diffs |= (__force unsigned long)macsec_p_ext->sci ^
9ee59a567b7907 Lior Nahmanson 2022-06-13  418  					 (__force unsigned long)macsec_skb_ext->sci;
9ee59a567b7907 Lior Nahmanson 2022-06-13  419  				diffs |= macsec_p_ext->offloaded ^ macsec_skb_ext->offloaded;
9ee59a567b7907 Lior Nahmanson 2022-06-13  420  			}
587652bbdd06ab Eric Dumazet   2021-11-15  421  #endif
587652bbdd06ab Eric Dumazet   2021-11-15  422  		}
587652bbdd06ab Eric Dumazet   2021-11-15  423  
587652bbdd06ab Eric Dumazet   2021-11-15  424  		NAPI_GRO_CB(p)->same_flow = !diffs;
587652bbdd06ab Eric Dumazet   2021-11-15  425  	}
587652bbdd06ab Eric Dumazet   2021-11-15  426  }
587652bbdd06ab Eric Dumazet   2021-11-15  427  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-07-13 19:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 11:19 [PATCH net-next v3 00/3] Introduce MACsec offload SKB extension Lior Nahmanson
2022-06-13 11:19 ` [PATCH net-next v3 1/3] net/macsec: Add MACsec skb extension Tx Data path support Lior Nahmanson
2022-06-13 11:19 ` [PATCH net-next v3 2/3] net/macsec: Add MACsec skb extension Rx " Lior Nahmanson
2022-06-14 13:55   ` Paolo Abeni
2022-06-14 16:14     ` Jakub Kicinski
2022-06-21 12:39       ` Lior Nahmanson
2022-06-21 19:26         ` Jakub Kicinski
2022-07-12  6:50           ` Lior Nahmanson
2022-07-13  0:01             ` Jakub Kicinski
2022-07-13  6:21               ` Lior Nahmanson
2022-07-13 18:34                 ` Jakub Kicinski
2022-07-13 19:31                   ` Saeed Mahameed
2022-06-13 11:19 ` [PATCH net-next v3 3/3] net/macsec: Move some code for sharing with various drivers that implements offload Lior Nahmanson
2022-06-15 13:16 [PATCH net-next v3 2/3] net/macsec: Add MACsec skb extension Rx Data path support kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.