* used to translate the reason to string.
*/
enum skb_drop_reason {
+ SKB_NOT_DROPPED_YET = 0,
SKB_DROP_REASON_NOT_SPECIFIED, /* drop reason is not specified */
SKB_DROP_REASON_NO_SOCKET, /* socket not found */
SKB_DROP_REASON_PKT_TOO_SMALL, /* packet size is too small */
return NULL;
return __tcp_md5_do_lookup(sk, l3index, addr, family);
}
-bool tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
- enum skb_drop_reason *reason,
- const void *saddr, const void *daddr,
- int family, int dif, int sdif);
+
+enum skb_drop_reason
+tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
+ const void *saddr, const void *daddr,
+ int family, int dif, int sdif);
#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key)
{
return NULL;
}
-static inline bool tcp_inbound_md5_hash(const struct sock *sk,
- const struct sk_buff *skb,
- enum skb_drop_reason *reason,
- const void *saddr, const void *daddr,
- int family, int dif, int sdif)
+
+static inline enum skb_drop_reason
+tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
+ const void *saddr, const void *daddr,
+ int family, int dif, int sdif);
{
- return false;
+ return SKB_NOT_DROPPED_YET;
}
#define tcp_twsk_md5_key(twsk) NULL
#endif
EXPORT_SYMBOL(tcp_md5_hash_key);
/* Called with rcu_read_lock() */
-bool tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
- enum skb_drop_reason *reason,
- const void *saddr, const void *daddr,
- int family, int dif, int sdif)
+enum skb_drop_reason
+tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb,
+ const void *saddr, const void *daddr,
+ int family, int dif, int sdif)
{
/*
* This gets called for each TCP segment that arrives
/* We've parsed the options - do we have a hash? */
if (!hash_expected && !hash_location)
- return false;
+ return SKB_NOT_DROPPED_YET;
if (hash_expected && !hash_location) {
- *reason = SKB_DROP_REASON_TCP_MD5NOTFOUND;
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND);
- return true;
+ return SKB_DROP_REASON_TCP_MD5NOTFOUND;
}
if (!hash_expected && hash_location) {
- *reason = SKB_DROP_REASON_TCP_MD5UNEXPECTED;
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED);
- return true;
+ return SKB_DROP_REASON_TCP_MD5UNEXPECTED;
}
/* check the signature */
NULL, skb);
if (genhash || memcmp(hash_location, newhash, 16) != 0) {
- *reason = SKB_DROP_REASON_TCP_MD5FAILURE;
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);
if (family == AF_INET) {
net_info_ratelimited("MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s L3 index %d\n",
saddr, ntohs(th->source),
daddr, ntohs(th->dest), l3index);
}
- return true;
+ return SKB_DROP_REASON_TCP_MD5FAILURE;
}
- return false;
+ return SKB_NOT_DROPPED_YET;
}
EXPORT_SYMBOL(tcp_inbound_md5_hash);
struct sock *nsk;
sk = req->rsk_listener;
- if (unlikely(tcp_inbound_md5_hash(sk, skb, &drop_reason,
- &iph->saddr, &iph->daddr,
- AF_INET, dif, sdif))) {
+ drop_reason = tcp_inbound_md5_hash(sk, skb,
+ &iph->saddr, &iph->daddr,
+ AF_INET, dif, sdif);
+ if (unlikely(drop_reason)) {
sk_drops_add(sk, skb);
reqsk_put(req);
goto discard_it;
goto discard_and_relse;
}
- if (tcp_inbound_md5_hash(sk, skb, &drop_reason, &iph->saddr,
- &iph->daddr, AF_INET, dif, sdif))
+ drop_reason = tcp_inbound_md5_hash(sk, skb, &iph->saddr,
+ &iph->daddr, AF_INET, dif, sdif);
+ if (drop_reason)
goto discard_and_relse;
nf_reset_ct(skb);
struct sock *nsk;
sk = req->rsk_listener;
- if (tcp_inbound_md5_hash(sk, skb, &drop_reason, &hdr->saddr,
- &hdr->daddr, AF_INET6, dif, sdif)) {
+ drop_reason = tcp_inbound_md5_hash(sk, skb,
+ &hdr->saddr, &hdr->daddr,
+ AF_INET6, dif, sdif);
+ if (drop_reason) {
sk_drops_add(sk, skb);
reqsk_put(req);
goto discard_it;
goto discard_and_relse;
}
- if (tcp_inbound_md5_hash(sk, skb, &drop_reason, &hdr->saddr,
- &hdr->daddr, AF_INET6, dif, sdif))
+ drop_reason = tcp_inbound_md5_hash(sk, skb, &hdr->saddr, &hdr->daddr,
+ AF_INET6, dif, sdif);
+ if (drop_reason)
goto discard_and_relse;
if (tcp_filter(sk, skb)) {