@@ -1863,12 +1863,6 @@ tcp_md5_do_lookup_any_l3index(const struct sock *sk,
18631863 return __tcp_md5_do_lookup (sk , 0 , addr , family , true);
18641864}
18651865
1866- enum skb_drop_reason
1867- tcp_inbound_md5_hash (const struct sock * sk , const struct sk_buff * skb ,
1868- const void * saddr , const void * daddr ,
1869- int family , int l3index , const __u8 * hash_location );
1870-
1871-
18721866#define tcp_twsk_md5_key (twsk ) ((twsk)->tw_md5_key)
18731867#else
18741868static inline struct tcp_md5sig_key *
@@ -1885,13 +1879,6 @@ tcp_md5_do_lookup_any_l3index(const struct sock *sk,
18851879 return NULL ;
18861880}
18871881
1888- static inline enum skb_drop_reason
1889- tcp_inbound_md5_hash (const struct sock * sk , const struct sk_buff * skb ,
1890- const void * saddr , const void * daddr ,
1891- int family , int l3index , const __u8 * hash_location )
1892- {
1893- return SKB_NOT_DROPPED_YET ;
1894- }
18951882#define tcp_twsk_md5_key (twsk ) NULL
18961883#endif
18971884
@@ -2386,21 +2373,15 @@ static inline void tcp_get_current_key(const struct sock *sk,
23862373
23872374static inline bool tcp_key_is_md5 (const struct tcp_key * key )
23882375{
2389- #ifdef CONFIG_TCP_MD5SIG
2390- if (static_branch_unlikely (& tcp_md5_needed .key ) &&
2391- key -> type == TCP_KEY_MD5 )
2392- return true;
2393- #endif
2376+ if (static_branch_tcp_md5 ())
2377+ return key -> type == TCP_KEY_MD5 ;
23942378 return false;
23952379}
23962380
23972381static inline bool tcp_key_is_ao (const struct tcp_key * key )
23982382{
2399- #ifdef CONFIG_TCP_AO
2400- if (static_branch_unlikely (& tcp_ao_needed .key ) &&
2401- key -> type == TCP_KEY_AO )
2402- return true;
2403- #endif
2383+ if (static_branch_tcp_ao ())
2384+ return key -> type == TCP_KEY_AO ;
24042385 return false;
24052386}
24062387
@@ -2812,66 +2793,9 @@ static inline bool tcp_ao_required(struct sock *sk, const void *saddr,
28122793 return false;
28132794}
28142795
2815- /* Called with rcu_read_lock() */
2816- static inline enum skb_drop_reason
2817- tcp_inbound_hash (struct sock * sk , const struct request_sock * req ,
2818- const struct sk_buff * skb ,
2819- const void * saddr , const void * daddr ,
2820- int family , int dif , int sdif )
2821- {
2822- const struct tcphdr * th = tcp_hdr (skb );
2823- const struct tcp_ao_hdr * aoh ;
2824- const __u8 * md5_location ;
2825- int l3index ;
2826-
2827- /* Invalid option or two times meet any of auth options */
2828- if (tcp_parse_auth_options (th , & md5_location , & aoh )) {
2829- tcp_hash_fail ("TCP segment has incorrect auth options set" ,
2830- family , skb , "" );
2831- return SKB_DROP_REASON_TCP_AUTH_HDR ;
2832- }
2833-
2834- if (req ) {
2835- if (tcp_rsk_used_ao (req ) != !!aoh ) {
2836- NET_INC_STATS (sock_net (sk ), LINUX_MIB_TCPAOBAD );
2837- tcp_hash_fail ("TCP connection can't start/end using TCP-AO" ,
2838- family , skb , "%s" ,
2839- !aoh ? "missing AO" : "AO signed" );
2840- return SKB_DROP_REASON_TCP_AOFAILURE ;
2841- }
2842- }
2843-
2844- /* sdif set, means packet ingressed via a device
2845- * in an L3 domain and dif is set to the l3mdev
2846- */
2847- l3index = sdif ? dif : 0 ;
2848-
2849- /* Fast path: unsigned segments */
2850- if (likely (!md5_location && !aoh )) {
2851- /* Drop if there's TCP-MD5 or TCP-AO key with any rcvid/sndid
2852- * for the remote peer. On TCP-AO established connection
2853- * the last key is impossible to remove, so there's
2854- * always at least one current_key.
2855- */
2856- if (tcp_ao_required (sk , saddr , family , l3index , true)) {
2857- tcp_hash_fail ("AO hash is required, but not found" ,
2858- family , skb , "L3 index %d" , l3index );
2859- return SKB_DROP_REASON_TCP_AONOTFOUND ;
2860- }
2861- if (unlikely (tcp_md5_do_lookup (sk , l3index , saddr , family ))) {
2862- NET_INC_STATS (sock_net (sk ), LINUX_MIB_TCPMD5NOTFOUND );
2863- tcp_hash_fail ("MD5 Hash not found" ,
2864- family , skb , "L3 index %d" , l3index );
2865- return SKB_DROP_REASON_TCP_MD5NOTFOUND ;
2866- }
2867- return SKB_NOT_DROPPED_YET ;
2868- }
2869-
2870- if (aoh )
2871- return tcp_inbound_ao_hash (sk , skb , family , req , l3index , aoh );
2872-
2873- return tcp_inbound_md5_hash (sk , skb , saddr , daddr , family ,
2874- l3index , md5_location );
2875- }
2796+ enum skb_drop_reason tcp_inbound_hash (struct sock * sk ,
2797+ const struct request_sock * req , const struct sk_buff * skb ,
2798+ const void * saddr , const void * daddr ,
2799+ int family , int dif , int sdif );
28762800
28772801#endif /* _TCP_H */
0 commit comments