Skip to content

Commit 7744388

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
tcp: md5: remove redundant l3flag variable
The l3flag variable was redundant as it duplicated the value of the 'flags' variable which already contains the interface index flag status from cmd.tcpm_flags. This cleanup simplifies the code by eliminating unnecessary variable duplication. Changes: 1. Remove l3flag variable declarations 2. Replace l3flag usage with existing 'flags' variable 3. Maintain identical functionality with reduced complexity Signed-off-by: Geliang Tang <[email protected]>
1 parent 7507f19 commit 7744388

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,6 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
15191519
const union tcp_md5_addr *addr;
15201520
u8 prefixlen = 32;
15211521
int l3index = 0;
1522-
bool l3flag;
15231522
u8 flags;
15241523

15251524
if (optlen < sizeof(cmd))
@@ -1532,7 +1531,6 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
15321531
return -EINVAL;
15331532

15341533
flags = cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX;
1535-
l3flag = cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX;
15361534

15371535
if (optname == TCP_MD5SIG_EXT &&
15381536
cmd.tcpm_flags & TCP_MD5SIG_FLAG_PREFIX) {
@@ -1541,8 +1539,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
15411539
return -EINVAL;
15421540
}
15431541

1544-
if (optname == TCP_MD5SIG_EXT && cmd.tcpm_ifindex &&
1545-
cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX) {
1542+
if (optname == TCP_MD5SIG_EXT && cmd.tcpm_ifindex && flags) {
15461543
struct net_device *dev;
15471544

15481545
rcu_read_lock();
@@ -1570,7 +1567,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, int optname,
15701567
/* Don't allow keys for peers that have a matching TCP-AO key.
15711568
* See the comment in tcp_ao_add_cmd()
15721569
*/
1573-
if (tcp_ao_required(sk, addr, AF_INET, l3flag ? l3index : -1, false))
1570+
if (tcp_ao_required(sk, addr, AF_INET, flags ? l3index : -1, false))
15741571
return -EKEYREJECTED;
15751572

15761573
return tcp_md5_do_add(sk, addr, AF_INET, prefixlen, l3index, flags,

net/ipv6/tcp_ipv6.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
610610
union tcp_ao_addr *addr;
611611
int l3index = 0;
612612
u8 prefixlen;
613-
bool l3flag;
614613
u8 flags;
615614

616615
if (optlen < sizeof(cmd))
@@ -623,7 +622,6 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
623622
return -EINVAL;
624623

625624
flags = cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX;
626-
l3flag = cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX;
627625

628626
if (optname == TCP_MD5SIG_EXT &&
629627
cmd.tcpm_flags & TCP_MD5SIG_FLAG_PREFIX) {
@@ -635,8 +633,7 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
635633
prefixlen = ipv6_addr_v4mapped(&sin6->sin6_addr) ? 32 : 128;
636634
}
637635

638-
if (optname == TCP_MD5SIG_EXT && cmd.tcpm_ifindex &&
639-
cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX) {
636+
if (optname == TCP_MD5SIG_EXT && cmd.tcpm_ifindex && flags) {
640637
struct net_device *dev;
641638

642639
rcu_read_lock();
@@ -671,7 +668,7 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
671668
* See the comment in tcp_ao_add_cmd()
672669
*/
673670
if (tcp_ao_required(sk, addr, AF_INET,
674-
l3flag ? l3index : -1, false))
671+
flags ? l3index : -1, false))
675672
return -EKEYREJECTED;
676673
return tcp_md5_do_add(sk, addr,
677674
AF_INET, prefixlen, l3index, flags,
@@ -683,7 +680,7 @@ static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
683680
/* Don't allow keys for peers that have a matching TCP-AO key.
684681
* See the comment in tcp_ao_add_cmd()
685682
*/
686-
if (tcp_ao_required(sk, addr, AF_INET6, l3flag ? l3index : -1, false))
683+
if (tcp_ao_required(sk, addr, AF_INET6, flags ? l3index : -1, false))
687684
return -EKEYREJECTED;
688685

689686
return tcp_md5_do_add(sk, addr, AF_INET6, prefixlen, l3index, flags,

0 commit comments

Comments
 (0)