|
|
@@ -99,6 +99,12 @@ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_NF_CT_PROTO_UDPLITE
|
|
|
+static void udplite_error_log(const struct sk_buff *skb, struct net *net,
|
|
|
+ u8 pf, const char *msg)
|
|
|
+{
|
|
|
+ nf_l4proto_log_invalid(skb, net, pf, IPPROTO_UDPLITE, "%s", msg);
|
|
|
+}
|
|
|
+
|
|
|
static int udplite_error(struct net *net, struct nf_conn *tmpl,
|
|
|
struct sk_buff *skb,
|
|
|
unsigned int dataoff,
|
|
|
@@ -112,9 +118,7 @@ static int udplite_error(struct net *net, struct nf_conn *tmpl,
|
|
|
/* Header is too small? */
|
|
|
hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
|
|
|
if (!hdr) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDPLITE))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udplite: short packet ");
|
|
|
+ udplite_error_log(skb, net, pf, "short packet");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|
|
|
@@ -122,17 +126,13 @@ static int udplite_error(struct net *net, struct nf_conn *tmpl,
|
|
|
if (cscov == 0) {
|
|
|
cscov = udplen;
|
|
|
} else if (cscov < sizeof(*hdr) || cscov > udplen) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDPLITE))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udplite: invalid checksum coverage ");
|
|
|
+ udplite_error_log(skb, net, pf, "invalid checksum coverage");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|
|
|
/* UDPLITE mandates checksums */
|
|
|
if (!hdr->check) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDPLITE))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udplite: checksum missing ");
|
|
|
+ udplite_error_log(skb, net, pf, "checksum missing");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|
|
|
@@ -140,9 +140,7 @@ static int udplite_error(struct net *net, struct nf_conn *tmpl,
|
|
|
if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
|
|
|
nf_checksum_partial(skb, hooknum, dataoff, cscov, IPPROTO_UDP,
|
|
|
pf)) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDPLITE))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udplite: bad UDPLite checksum ");
|
|
|
+ udplite_error_log(skb, net, pf, "bad checksum");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|
|
|
@@ -150,6 +148,12 @@ static int udplite_error(struct net *net, struct nf_conn *tmpl,
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+static void udp_error_log(const struct sk_buff *skb, struct net *net,
|
|
|
+ u8 pf, const char *msg)
|
|
|
+{
|
|
|
+ nf_l4proto_log_invalid(skb, net, pf, IPPROTO_UDP, "%s", msg);
|
|
|
+}
|
|
|
+
|
|
|
static int udp_error(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
|
|
|
unsigned int dataoff,
|
|
|
u_int8_t pf,
|
|
|
@@ -162,17 +166,13 @@ static int udp_error(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
|
|
|
/* Header is too small? */
|
|
|
hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
|
|
|
if (hdr == NULL) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDP))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udp: short packet ");
|
|
|
+ udp_error_log(skb, net, pf, "short packet");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|
|
|
/* Truncated/malformed packets */
|
|
|
if (ntohs(hdr->len) > udplen || ntohs(hdr->len) < sizeof(*hdr)) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDP))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udp: truncated/malformed packet ");
|
|
|
+ udp_error_log(skb, net, pf, "truncated/malformed packet");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|
|
|
@@ -186,9 +186,7 @@ static int udp_error(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
|
|
|
* FIXME: Source route IP option packets --RR */
|
|
|
if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
|
|
|
nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) {
|
|
|
- if (LOG_INVALID(net, IPPROTO_UDP))
|
|
|
- nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
|
|
|
- "nf_ct_udp: bad UDP checksum ");
|
|
|
+ udp_error_log(skb, net, pf, "bad checksum");
|
|
|
return -NF_ACCEPT;
|
|
|
}
|
|
|
|