#endif
+#if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO)
+/*
+ * Parse Signature options
+ */
+int tcp_do_parse_auth_options(const struct tcphdr *th,
+ const u8 **md5_hash, const u8 **ao_hash)
+{
+ int length = (th->doff << 2) - sizeof(*th);
+ const u8 *ptr = (const u8 *)(th + 1);
+ unsigned int minlen = TCPOLEN_MD5SIG;
+
+ if (IS_ENABLED(CONFIG_TCP_AO))
+ minlen = sizeof(struct tcp_ao_hdr) + 1;
+
+ *md5_hash = NULL;
+ *ao_hash = NULL;
+
+ /* If not enough data remaining, we can short cut */
+ while (length >= minlen) {
+ int opcode = *ptr++;
+ int opsize;
+
+ switch (opcode) {
+ case TCPOPT_EOL:
+ return 0;
+ case TCPOPT_NOP:
+ length--;
+ continue;
+ default:
+ opsize = *ptr++;
+ if (opsize < 2 || opsize > length)
+ return -EINVAL;
+ if (opcode == TCPOPT_MD5SIG) {
+ if (opsize != TCPOLEN_MD5SIG)
+ return -EINVAL;
+ if (unlikely(*md5_hash || *ao_hash))
+ return -EEXIST;
+ *md5_hash = ptr;
+ } else if (opcode == TCPOPT_AO) {
+ if (opsize <= sizeof(struct tcp_ao_hdr))
+ return -EINVAL;
+ if (unlikely(*md5_hash || *ao_hash))
+ return -EEXIST;
+ *ao_hash = ptr;
+ }
+ }
+ ptr += opsize - 2;
+ length -= opsize;
+ }
+ return 0;
+}
+EXPORT_IPV6_MOD(tcp_do_parse_auth_options);
+#endif
+
/* Called with rcu_read_lock() */
enum skb_drop_reason
tcp_inbound_hash(struct sock *sk, const struct request_sock *req,
return true;
}
-#if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO)
-/*
- * Parse Signature options
- */
-int tcp_do_parse_auth_options(const struct tcphdr *th,
- const u8 **md5_hash, const u8 **ao_hash)
-{
- int length = (th->doff << 2) - sizeof(*th);
- const u8 *ptr = (const u8 *)(th + 1);
- unsigned int minlen = TCPOLEN_MD5SIG;
-
- if (IS_ENABLED(CONFIG_TCP_AO))
- minlen = sizeof(struct tcp_ao_hdr) + 1;
-
- *md5_hash = NULL;
- *ao_hash = NULL;
-
- /* If not enough data remaining, we can short cut */
- while (length >= minlen) {
- int opcode = *ptr++;
- int opsize;
-
- switch (opcode) {
- case TCPOPT_EOL:
- return 0;
- case TCPOPT_NOP:
- length--;
- continue;
- default:
- opsize = *ptr++;
- if (opsize < 2 || opsize > length)
- return -EINVAL;
- if (opcode == TCPOPT_MD5SIG) {
- if (opsize != TCPOLEN_MD5SIG)
- return -EINVAL;
- if (unlikely(*md5_hash || *ao_hash))
- return -EEXIST;
- *md5_hash = ptr;
- } else if (opcode == TCPOPT_AO) {
- if (opsize <= sizeof(struct tcp_ao_hdr))
- return -EINVAL;
- if (unlikely(*md5_hash || *ao_hash))
- return -EEXIST;
- *ao_hash = ptr;
- }
- }
- ptr += opsize - 2;
- length -= opsize;
- }
- return 0;
-}
-EXPORT_SYMBOL(tcp_do_parse_auth_options);
-#endif
-
/* Sorry, PAWS as specified is broken wrt. pure-ACKs -DaveM
*
* It is not fatal. If this ACK does _not_ change critical state (seqs, window)