···743743}744744745745/**746746- * vti6_tnl_ioctl - configure vti6 tunnels from userspace746746+ * vti6_ioctl - configure vti6 tunnels from userspace747747 * @dev: virtual device associated with tunnel748748 * @ifr: parameters passed from userspace749749 * @cmd: command to be performed
+2-4
net/ipv6/xfrm6_state.c
···6060static int6161__xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass)6262{6363- int i;6363+ int count[XFRM_MAX_DEPTH] = { };6464 int class[XFRM_MAX_DEPTH];6565- int count[maxclass];6666-6767- memset(count, 0, sizeof(count));6565+ int i;68666967 for (i = 0; i < n; i++) {7068 int c;
+7-2
net/xfrm/xfrm_state.c
···42424343static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024;4444static __read_mostly seqcount_t xfrm_state_hash_generation = SEQCNT_ZERO(xfrm_state_hash_generation);4545+static struct kmem_cache *xfrm_state_cache __ro_after_init;45464647static DECLARE_WORK(xfrm_state_gc_work, xfrm_state_gc_task);4748static HLIST_HEAD(xfrm_state_gc_list);···452451 }453452 xfrm_dev_state_free(x);454453 security_xfrm_state_free(x);455455- kfree(x);454454+ kmem_cache_free(xfrm_state_cache, x);456455}457456458457static void xfrm_state_gc_task(struct work_struct *work)···564563{565564 struct xfrm_state *x;566565567567- x = kzalloc(sizeof(struct xfrm_state), GFP_ATOMIC);566566+ x = kmem_cache_alloc(xfrm_state_cache, GFP_ATOMIC | __GFP_ZERO);568567569568 if (x) {570569 write_pnet(&x->xs_net, net);···23072306int __net_init xfrm_state_init(struct net *net)23082307{23092308 unsigned int sz;23092309+23102310+ if (net_eq(net, &init_net))23112311+ xfrm_state_cache = KMEM_CACHE(xfrm_state,23122312+ SLAB_HWCACHE_ALIGN | SLAB_PANIC);2310231323112314 INIT_LIST_HEAD(&net->xfrm.state_all);23122315
+103
tools/testing/selftests/net/rtnetlink.sh
···502502 echo "PASS: macsec"503503}504504505505+#-------------------------------------------------------------------506506+# Example commands507507+# ip x s add proto esp src 14.0.0.52 dst 14.0.0.70 \508508+# spi 0x07 mode transport reqid 0x07 replay-window 32 \509509+# aead 'rfc4106(gcm(aes))' 1234567890123456dcba 128 \510510+# sel src 14.0.0.52/24 dst 14.0.0.70/24511511+# ip x p add dir out src 14.0.0.52/24 dst 14.0.0.70/24 \512512+# tmpl proto esp src 14.0.0.52 dst 14.0.0.70 \513513+# spi 0x07 mode transport reqid 0x07514514+#515515+# Subcommands not tested516516+# ip x s update517517+# ip x s allocspi518518+# ip x s deleteall519519+# ip x p update520520+# ip x p deleteall521521+# ip x p set522522+#-------------------------------------------------------------------523523+kci_test_ipsec()524524+{525525+ srcip="14.0.0.52"526526+ dstip="14.0.0.70"527527+ algo="aead rfc4106(gcm(aes)) 0x3132333435363738393031323334353664636261 128"528528+529529+ # flush to be sure there's nothing configured530530+ ip x s flush ; ip x p flush531531+ check_err $?532532+533533+ # start the monitor in the background534534+ tmpfile=`mktemp ipsectestXXX`535535+ ip x m > $tmpfile &536536+ mpid=$!537537+ sleep 0.2538538+539539+ ipsecid="proto esp src $srcip dst $dstip spi 0x07"540540+ ip x s add $ipsecid \541541+ mode transport reqid 0x07 replay-window 32 \542542+ $algo sel src $srcip/24 dst $dstip/24543543+ check_err $?544544+545545+ lines=`ip x s list | grep $srcip | grep $dstip | wc -l`546546+ test $lines -eq 2547547+ check_err $?548548+549549+ ip x s count | grep -q "SAD count 1"550550+ check_err $?551551+552552+ lines=`ip x s get $ipsecid | grep $srcip | grep $dstip | wc -l`553553+ test $lines -eq 2554554+ check_err $?555555+556556+ ip x s delete $ipsecid557557+ check_err $?558558+559559+ lines=`ip x s list | wc -l`560560+ test $lines -eq 0561561+ check_err $?562562+563563+ ipsecsel="dir out src $srcip/24 dst $dstip/24"564564+ ip x p add $ipsecsel \565565+ tmpl proto esp src $srcip dst $dstip \566566+ spi 0x07 mode transport reqid 0x07567567+ check_err $?568568+569569+ lines=`ip x p list | grep $srcip | grep $dstip | wc -l`570570+ test $lines -eq 2571571+ check_err $?572572+573573+ ip x p count | grep -q "SPD IN 0 OUT 1 FWD 0"574574+ check_err $?575575+576576+ lines=`ip x p get $ipsecsel | grep $srcip | grep $dstip | wc -l`577577+ test $lines -eq 2578578+ check_err $?579579+580580+ ip x p delete $ipsecsel581581+ check_err $?582582+583583+ lines=`ip x p list | wc -l`584584+ test $lines -eq 0585585+ check_err $?586586+587587+ # check the monitor results588588+ kill $mpid589589+ lines=`wc -l $tmpfile | cut "-d " -f1`590590+ test $lines -eq 20591591+ check_err $?592592+ rm -rf $tmpfile593593+594594+ # clean up any leftovers595595+ ip x s flush596596+ check_err $?597597+ ip x p flush598598+ check_err $?599599+600600+ if [ $ret -ne 0 ]; then601601+ echo "FAIL: ipsec"602602+ return 1603603+ fi604604+ echo "PASS: ipsec"605605+}606606+505607kci_test_gretap()506608{507609 testns="testns"···857755 kci_test_vrf858756 kci_test_encap859757 kci_test_macsec758758+ kci_test_ipsec860759861760 kci_del_dummy862761}