Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pktgen-code-cleanup'

Peter Seiderer says:

====================
net: pktgen: fix checkpatch code style errors/warnings

Fix checkpatch detected code style errors/warnings detected in
the file net/core/pktgen.c (remaining checkpatch checks will be addressed
in a follow up patch set).
====================

Link: https://patch.msgid.link/20250410071749.30505-1-ps.report@gmx.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+50 -29
+50 -29
net/core/pktgen.c
··· 177 177 #define MAX_IMIX_ENTRIES 20 178 178 #define IMIX_PRECISION 100 /* Precision of IMIX distribution */ 179 179 180 - #define func_enter() pr_debug("entering %s\n", __func__); 180 + #define func_enter() pr_debug("entering %s\n", __func__) 181 181 182 182 #define PKT_FLAGS \ 183 183 pf(IPV6) /* Interface in IPV6 Mode */ \ ··· 231 231 #define M_QUEUE_XMIT 2 /* Inject packet into qdisc */ 232 232 233 233 /* If lock -- protects updating of if_list */ 234 - #define if_lock(t) mutex_lock(&(t->if_lock)); 235 - #define if_unlock(t) mutex_unlock(&(t->if_lock)); 234 + #define if_lock(t) mutex_lock(&(t->if_lock)) 235 + #define if_unlock(t) mutex_unlock(&(t->if_lock)) 236 236 237 237 /* Used to help with determining the pkts on receive */ 238 238 #define PKTGEN_MAGIC 0xbe9be955 ··· 283 283 int pkt_overhead; /* overhead for MPLS, VLANs, IPSEC etc */ 284 284 int nfrags; 285 285 int removal_mark; /* non-zero => the device is marked for 286 - * removal by worker thread */ 286 + * removal by worker thread 287 + */ 287 288 288 289 struct page *page; 289 290 u64 delay; /* nano-seconds */ ··· 347 346 __u16 udp_dst_max; /* exclusive, dest UDP port */ 348 347 349 348 /* DSCP + ECN */ 350 - __u8 tos; /* six MSB of (former) IPv4 TOS 351 - are for dscp codepoint */ 352 - __u8 traffic_class; /* ditto for the (former) Traffic Class in IPv6 353 - (see RFC 3260, sec. 4) */ 349 + __u8 tos; /* six MSB of (former) IPv4 TOS 350 + * are for dscp codepoint 351 + */ 352 + __u8 traffic_class; /* ditto for the (former) Traffic Class in IPv6 353 + * (see RFC 3260, sec. 4) 354 + */ 354 355 355 356 /* IMIX */ 356 357 unsigned int n_imix_entries; ··· 392 389 393 390 __u8 hh[14]; 394 391 /* = { 395 - 0x00, 0x80, 0xC8, 0x79, 0xB3, 0xCB, 396 - 397 - We fill in SRC address later 398 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 399 - 0x08, 0x00 400 - }; 392 + * 0x00, 0x80, 0xC8, 0x79, 0xB3, 0xCB, 393 + * 394 + * We fill in SRC address later 395 + * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 396 + * 0x08, 0x00 397 + * }; 401 398 */ 402 399 __u16 pad; /* pad out the hh struct to an even 16 bytes */ 403 400 ··· 461 458 char result[512]; 462 459 463 460 /* Field for thread to receive "posted" events terminate, 464 - stop ifs etc. */ 461 + * stop ifs etc. 462 + */ 465 463 466 464 u32 control; 467 465 int cpu; ··· 476 472 #define FIND 0 477 473 478 474 static const char version[] = 479 - "Packet Generator for packet performance testing. " 480 - "Version: " VERSION "\n"; 475 + "Packet Generator for packet performance testing. Version: " VERSION "\n"; 481 476 482 477 static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *i); 483 478 static int pktgen_add_device(struct pktgen_thread *t, const char *ifname); ··· 627 624 seq_printf(seq, "%pM\n", pkt_dev->dst_mac); 628 625 629 626 seq_printf(seq, 630 - " udp_src_min: %d udp_src_max: %d" 631 - " udp_dst_min: %d udp_dst_max: %d\n", 627 + " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n", 632 628 pkt_dev->udp_src_min, pkt_dev->udp_src_max, 633 629 pkt_dev->udp_dst_min, pkt_dev->udp_dst_max); 634 630 ··· 756 754 for (; i < maxlen; i++) { 757 755 int value; 758 756 char c; 757 + 759 758 if (get_user(c, &user_buffer[i])) 760 759 return -EFAULT; 761 760 value = hex_to_bin(c); ··· 776 773 777 774 for (i = 0; i < maxlen; i++) { 778 775 char c; 776 + 779 777 if (get_user(c, &user_buffer[i])) 780 778 return -EFAULT; 781 779 switch (c) { ··· 803 799 804 800 for (i = 0; i < maxlen; i++) { 805 801 char c; 802 + 806 803 if (get_user(c, &user_buffer[i])) 807 804 return -EFAULT; 808 805 if ((c >= '0') && (c <= '9')) { ··· 821 816 822 817 for (i = 0; i < maxlen; i++) { 823 818 char c; 819 + 824 820 if (get_user(c, &user_buffer[i])) 825 821 return -EFAULT; 826 822 switch (c) { ··· 980 974 } 981 975 982 976 static ssize_t pktgen_if_write(struct file *file, 983 - const char __user * user_buffer, size_t count, 984 - loff_t * offset) 977 + const char __user *user_buffer, size_t count, 978 + loff_t *offset) 985 979 { 986 980 struct seq_file *seq = file->private_data; 987 981 struct pktgen_dev *pkt_dev = seq->private; ··· 1915 1909 } 1916 1910 1917 1911 static ssize_t pktgen_thread_write(struct file *file, 1918 - const char __user * user_buffer, 1919 - size_t count, loff_t * offset) 1912 + const char __user *user_buffer, 1913 + size_t count, loff_t *offset) 1920 1914 { 1921 1915 struct seq_file *seq = file->private_data; 1922 1916 struct pktgen_thread *t = seq->private; ··· 1968 1962 1969 1963 if (!strcmp(name, "add_device")) { 1970 1964 char f[32]; 1965 + 1971 1966 memset(f, 0, 32); 1972 1967 max = min(sizeof(f) - 1, count - i); 1973 1968 len = strn_len(&user_buffer[i], max); ··· 2404 2397 2405 2398 /* If there was already an IPSEC SA, we keep it as is, else 2406 2399 * we go look for it ... 2407 - */ 2400 + */ 2408 2401 #define DUMMY_MARK 0 2409 2402 static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) 2410 2403 { 2411 2404 #ifdef CONFIG_XFRM 2412 2405 struct xfrm_state *x = pkt_dev->flows[flow].x; 2413 2406 struct pktgen_net *pn = net_generic(dev_net(pkt_dev->odev), pg_net_id); 2407 + 2414 2408 if (!x) { 2415 2409 2416 2410 if (pkt_dev->spi) { ··· 2444 2436 2445 2437 else if (pkt_dev->queue_map_min <= pkt_dev->queue_map_max) { 2446 2438 __u16 t; 2439 + 2447 2440 if (pkt_dev->flags & F_QUEUE_MAP_RND) { 2448 2441 t = get_random_u32_inclusive(pkt_dev->queue_map_min, 2449 2442 pkt_dev->queue_map_max); ··· 2526 2517 2527 2518 if (pkt_dev->flags & F_MPLS_RND) { 2528 2519 unsigned int i; 2520 + 2529 2521 for (i = 0; i < pkt_dev->nr_labels; i++) 2530 2522 if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) 2531 2523 pkt_dev->labels[i] = MPLS_STACK_BOTTOM | ··· 2571 2561 imx = ntohl(pkt_dev->saddr_max); 2572 2562 if (imn < imx) { 2573 2563 __u32 t; 2564 + 2574 2565 if (pkt_dev->flags & F_IPSRC_RND) 2575 2566 t = get_random_u32_inclusive(imn, imx - 1); 2576 2567 else { ··· 2592 2581 if (imn < imx) { 2593 2582 __u32 t; 2594 2583 __be32 s; 2584 + 2595 2585 if (pkt_dev->flags & F_IPDST_RND) { 2596 2586 2597 2587 do { ··· 2640 2628 2641 2629 if (pkt_dev->min_pkt_size < pkt_dev->max_pkt_size) { 2642 2630 __u32 t; 2631 + 2643 2632 if (pkt_dev->flags & F_TXSIZE_RND) { 2644 2633 t = get_random_u32_inclusive(pkt_dev->min_pkt_size, 2645 2634 pkt_dev->max_pkt_size - 1); ··· 2707 2694 if (!x) 2708 2695 return 0; 2709 2696 /* XXX: we dont support tunnel mode for now until 2710 - * we resolve the dst issue */ 2697 + * we resolve the dst issue 2698 + */ 2711 2699 if ((x->props.mode != XFRM_MODE_TRANSPORT) && (pkt_dev->spi == 0)) 2712 2700 return 0; 2713 2701 ··· 2743 2729 if (pkt_dev->cflows) { 2744 2730 /* let go of the SAs if we have them */ 2745 2731 int i; 2732 + 2746 2733 for (i = 0; i < pkt_dev->cflows; i++) { 2747 2734 struct xfrm_state *x = pkt_dev->flows[i].x; 2735 + 2748 2736 if (x) { 2749 2737 xfrm_state_put(x); 2750 2738 pkt_dev->flows[i].x = NULL; ··· 2761 2745 if (pkt_dev->flags & F_IPSEC) { 2762 2746 struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x; 2763 2747 int nhead = 0; 2748 + 2764 2749 if (x) { 2765 2750 struct ethhdr *eth; 2766 2751 struct iphdr *iph; ··· 2805 2788 static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) 2806 2789 { 2807 2790 unsigned int i; 2791 + 2808 2792 for (i = 0; i < pkt_dev->nr_labels; i++) 2809 2793 *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; 2810 2794 ··· 2918 2900 skb->dev = dev; 2919 2901 } 2920 2902 } else { 2921 - skb = __netdev_alloc_skb(dev, size, GFP_NOWAIT); 2903 + skb = __netdev_alloc_skb(dev, size, GFP_NOWAIT); 2922 2904 } 2923 2905 2924 2906 /* the caller pre-fetches from skb->data and reserves for the mac hdr */ ··· 2999 2981 skb->priority = pkt_dev->skb_priority; 3000 2982 3001 2983 memcpy(eth, pkt_dev->hh, 12); 3002 - *(__be16 *) & eth[12] = protocol; 2984 + *(__be16 *)&eth[12] = protocol; 3003 2985 3004 2986 /* Eth + IPh + UDPh + mpls */ 3005 2987 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - ··· 3491 3473 static void pktgen_resched(struct pktgen_dev *pkt_dev) 3492 3474 { 3493 3475 ktime_t idle_start = ktime_get(); 3476 + 3494 3477 schedule(); 3495 3478 pkt_dev->idle_acc += ktime_to_ns(ktime_sub(ktime_get(), idle_start)); 3496 3479 } ··· 3807 3788 * userspace on another CPU than the kthread. The if_lock() 3808 3789 * is used here to sync with concurrent instances of 3809 3790 * _rem_dev_from_if_list() invoked via kthread, which is also 3810 - * updating the if_list */ 3791 + * updating the if_list 3792 + */ 3811 3793 if_lock(t); 3812 3794 3813 3795 if (pkt_dev->pg_thread) { ··· 4003 3983 4004 3984 /* Remove proc before if_list entry, because add_device uses 4005 3985 * list to determine if interface already exist, avoid race 4006 - * with proc_create_data() */ 3986 + * with proc_create_data() 3987 + */ 4007 3988 proc_remove(pkt_dev->entry); 4008 3989 4009 3990 /* And update the thread if_list */