* [PATCH 2.6] iptables AH/ESP fix (1/3)
@ 2003-08-02 12:57 Harald Welte
0 siblings, 0 replies; only message in thread
From: Harald Welte @ 2003-08-02 12:57 UTC (permalink / raw)
To: David Miller; +Cc: Netfilter Development Mailinglist, Linux Kernel Mailinglist
[-- Attachment #1: Type: text/plain, Size: 2932 bytes --]
Hi Davem!
The below patch fixes logging of AH SPI's in the iptables LOG target.
It is the first of a series of three patches related to AH/ESP in
iptables. (you'll receive 2.4 updates later on)
Please apply, thanks.
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1535 -> 1.1536
# net/ipv4/netfilter/ipt_LOG.c 1.7 -> 1.8
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/07/21 kaber@trash.net 1.1536
# [NETFILTER]: Fix logging of AH spis
# --------------------------------------------
#
diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
--- a/net/ipv4/netfilter/ipt_LOG.c Thu May 22 01:36:54 2003
+++ b/net/ipv4/netfilter/ipt_LOG.c Mon Jul 21 01:30:34 2003
@@ -2,16 +2,15 @@
* This is a module which is used for logging packets.
*/
#include <linux/module.h>
+#include <linux/spinlock.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
-#include <linux/spinlock.h>
#include <net/icmp.h>
#include <net/udp.h>
#include <net/tcp.h>
-#include <linux/netfilter_ipv4/ip_tables.h>
-
-struct in_device;
#include <net/route.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_LOG.h>
#if 0
@@ -20,10 +19,6 @@
#define DEBUGP(format, args...)
#endif
-struct esphdr {
- __u32 spi;
-}; /* FIXME evil kludge */
-
/* Use lock to serialize, so printks don't overlap */
static spinlock_t log_lock = SPIN_LOCK_UNLOCKED;
@@ -256,13 +251,31 @@
break;
}
/* Max Length */
- case IPPROTO_AH:
+ case IPPROTO_AH: {
+ struct ip_auth_hdr ah;
+
+ if (ntohs(iph.frag_off) & IP_OFFSET)
+ break;
+
+ /* Max length: 9 "PROTO=AH " */
+ printk("PROTO=AH ");
+
+ /* Max length: 25 "INCOMPLETE [65535 bytes] " */
+ if (skb_copy_bits(skb, iphoff+iph.ihl*4, &ah, sizeof(ah)) < 0) {
+ printk("INCOMPLETE [%u bytes] ",
+ skb->len - iphoff - iph.ihl*4);
+ break;
+ }
+
+ /* Length: 15 "SPI=0xF1234567 " */
+ printk("SPI=0x%x ", ntohl(ah.spi));
+ break;
+ }
case IPPROTO_ESP: {
- struct esphdr esph;
- int esp = (iph.protocol==IPPROTO_ESP);
+ struct ip_esp_hdr esph;
/* Max length: 10 "PROTO=ESP " */
- printk("PROTO=%s ",esp? "ESP" : "AH");
+ printk("PROTO=ESP ");
if (ntohs(iph.frag_off) & IP_OFFSET)
break;
--
- Harald Welte <laforge@netfilter.org> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-08-02 13:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-02 12:57 [PATCH 2.6] iptables AH/ESP fix (1/3) Harald Welte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).