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.

tcp: move tcp_do_parse_auth_options() to net/ipv4/tcp.c

tcp_do_parse_auth_options() fast path user is tcp_inbound_hash().

Move tcp_do_parse_auth_options() right before tcp_inbound_hash()
so that it can be (auto)inlined by the compiler.

As a bonus, stack canary is removed from tcp_inbound_hash().

Also use EXPORT_IPV6_MOD(tcp_do_parse_auth_options).

$ scripts/bloat-o-meter -t vmlinux.0 vmlinux
add/remove: 0/0 grow/shrink: 1/0 up/down: 131/0 (131)
Function old new delta
tcp_inbound_hash 565 696 +131
Total: Before=25223788, After=25223919, chg +0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260303191243.557245-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
1d88db16 db739ff2

+54 -54
+54
net/ipv4/tcp.c
··· 4987 4987 4988 4988 #endif 4989 4989 4990 + #if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO) 4991 + /* 4992 + * Parse Signature options 4993 + */ 4994 + int tcp_do_parse_auth_options(const struct tcphdr *th, 4995 + const u8 **md5_hash, const u8 **ao_hash) 4996 + { 4997 + int length = (th->doff << 2) - sizeof(*th); 4998 + const u8 *ptr = (const u8 *)(th + 1); 4999 + unsigned int minlen = TCPOLEN_MD5SIG; 5000 + 5001 + if (IS_ENABLED(CONFIG_TCP_AO)) 5002 + minlen = sizeof(struct tcp_ao_hdr) + 1; 5003 + 5004 + *md5_hash = NULL; 5005 + *ao_hash = NULL; 5006 + 5007 + /* If not enough data remaining, we can short cut */ 5008 + while (length >= minlen) { 5009 + int opcode = *ptr++; 5010 + int opsize; 5011 + 5012 + switch (opcode) { 5013 + case TCPOPT_EOL: 5014 + return 0; 5015 + case TCPOPT_NOP: 5016 + length--; 5017 + continue; 5018 + default: 5019 + opsize = *ptr++; 5020 + if (opsize < 2 || opsize > length) 5021 + return -EINVAL; 5022 + if (opcode == TCPOPT_MD5SIG) { 5023 + if (opsize != TCPOLEN_MD5SIG) 5024 + return -EINVAL; 5025 + if (unlikely(*md5_hash || *ao_hash)) 5026 + return -EEXIST; 5027 + *md5_hash = ptr; 5028 + } else if (opcode == TCPOPT_AO) { 5029 + if (opsize <= sizeof(struct tcp_ao_hdr)) 5030 + return -EINVAL; 5031 + if (unlikely(*md5_hash || *ao_hash)) 5032 + return -EEXIST; 5033 + *ao_hash = ptr; 5034 + } 5035 + } 5036 + ptr += opsize - 2; 5037 + length -= opsize; 5038 + } 5039 + return 0; 5040 + } 5041 + EXPORT_IPV6_MOD(tcp_do_parse_auth_options); 5042 + #endif 5043 + 4990 5044 /* Called with rcu_read_lock() */ 4991 5045 enum skb_drop_reason 4992 5046 tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
-54
net/ipv4/tcp_input.c
··· 4714 4714 return true; 4715 4715 } 4716 4716 4717 - #if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO) 4718 - /* 4719 - * Parse Signature options 4720 - */ 4721 - int tcp_do_parse_auth_options(const struct tcphdr *th, 4722 - const u8 **md5_hash, const u8 **ao_hash) 4723 - { 4724 - int length = (th->doff << 2) - sizeof(*th); 4725 - const u8 *ptr = (const u8 *)(th + 1); 4726 - unsigned int minlen = TCPOLEN_MD5SIG; 4727 - 4728 - if (IS_ENABLED(CONFIG_TCP_AO)) 4729 - minlen = sizeof(struct tcp_ao_hdr) + 1; 4730 - 4731 - *md5_hash = NULL; 4732 - *ao_hash = NULL; 4733 - 4734 - /* If not enough data remaining, we can short cut */ 4735 - while (length >= minlen) { 4736 - int opcode = *ptr++; 4737 - int opsize; 4738 - 4739 - switch (opcode) { 4740 - case TCPOPT_EOL: 4741 - return 0; 4742 - case TCPOPT_NOP: 4743 - length--; 4744 - continue; 4745 - default: 4746 - opsize = *ptr++; 4747 - if (opsize < 2 || opsize > length) 4748 - return -EINVAL; 4749 - if (opcode == TCPOPT_MD5SIG) { 4750 - if (opsize != TCPOLEN_MD5SIG) 4751 - return -EINVAL; 4752 - if (unlikely(*md5_hash || *ao_hash)) 4753 - return -EEXIST; 4754 - *md5_hash = ptr; 4755 - } else if (opcode == TCPOPT_AO) { 4756 - if (opsize <= sizeof(struct tcp_ao_hdr)) 4757 - return -EINVAL; 4758 - if (unlikely(*md5_hash || *ao_hash)) 4759 - return -EEXIST; 4760 - *ao_hash = ptr; 4761 - } 4762 - } 4763 - ptr += opsize - 2; 4764 - length -= opsize; 4765 - } 4766 - return 0; 4767 - } 4768 - EXPORT_SYMBOL(tcp_do_parse_auth_options); 4769 - #endif 4770 - 4771 4717 /* Sorry, PAWS as specified is broken wrt. pure-ACKs -DaveM 4772 4718 * 4773 4719 * It is not fatal. If this ACK does _not_ change critical state (seqs, window)