* Re: [PATCH] forcedeth: TX handler changes (experimental)
From: Daniel Drake @ 2005-07-20 21:16 UTC (permalink / raw)
To: Manfred Spraul; +Cc: Linux Kernel Mailing List, Netdev, Ayaz Abdulla
In-Reply-To: <42D97DD0.6030207@colorfullife.com>
Manfred Spraul wrote:
> Autsch.
> Yes, you are right. Sorry for that, I should have reread the patch once
> more.
No problem :)
I've been running v0.38 since my last mail. No problems at all.
Thanks for your continued work on the driver.
Daniel
^ permalink raw reply
* RE: Delivery reports about your e-mail
From: iamthemonk @ 2005-07-20 19:31 UTC (permalink / raw)
To: netdev
Your message was received at Wed, 20 Jul 2005 19:31:11 +0000:
To: iamthemonk@bluebottle.com
Subject: Delivery reports about your e-mail
This account is protected by Bluebottle. Please click on the
following link to have your address added to the recipient's allowed
list and to ensure delivery of your email.
http://www.bluebottle.com/verification/6c63b99816f766f1785ff85235f3a38b
Bluebottle is a trademark of Bluebottle Solutions Pty Ltd
^ permalink raw reply
* Re: [PATCH 3/*] re-add NFC_ defines
From: David S. Miller @ 2005-07-20 19:05 UTC (permalink / raw)
To: laforge; +Cc: netdev, netfilter-devel
In-Reply-To: <20050720133137.GD4077@rama>
All 3 patches applied, thanks Harald.
^ permalink raw reply
* Re: [patch linux-2.6.13-rc2-gitXX 1/1] zatm: mailbox converted to pci_alloc_consistent()
From: David S. Miller @ 2005-07-20 19:02 UTC (permalink / raw)
To: romieu; +Cc: chas, netdev
In-Reply-To: <20050719223655.GA27724@electric-eye.fr.zoreil.com>
From: Francois Romieu <romieu@fr.zoreil.com>
Date: Wed, 20 Jul 2005 00:36:55 +0200
> mailbox converted to pci_alloc_consistent()
>
> - request_region() is not needed: zatm_init_one() issues
> pci_request_regions();
> - the warning related to kfree(zatm_dev->mbx_start) disappears;
>
> Compiled with i386 and sparc64 as target.
>
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
This looks great, applied.
^ permalink raw reply
* Re: [PATCH 1/8][ATM]: [zatm] eliminate kfree warning (from Tobias Hirning <sskyman@web.de>)
From: David S. Miller @ 2005-07-20 18:56 UTC (permalink / raw)
To: jakub; +Cc: chas, netdev
In-Reply-To: <20050720071919.GV4740@sunsite.mff.cuni.cz>
From: Jakub Jelinek <jakub@redhat.com>
Date: Wed, 20 Jul 2005 09:19:20 +0200
> This can't be right. zatm_dev->mbx_start[i] is allocated with:
Correct, Francois posted a much better fix and I'll put
that into my tree.
^ permalink raw reply
* Re: [patch linux-2.6.13-rc2-gitXX 1/1] zatm: mailbox converted to pci_alloc_consistent()
From: David S. Miller @ 2005-07-20 18:55 UTC (permalink / raw)
To: chas3, chas; +Cc: romieu, netdev
In-Reply-To: <200507201507.j6KF7Buk009484@ginger.cmf.nrl.navy.mil>
From: chas@cmf.nrl.navy.mil
Subject: Re: [patch linux-2.6.13-rc2-gitXX 1/1] zatm: mailbox converted to pci_alloc_consistent()
Date: Wed, 20 Jul 2005 11:07:12 -0400
> In message <20050719223655.GA27724@electric-eye.fr.zoreil.com>,Francois Romieu
> writes:
> >+ mbx = pci_alloc_consistent(pdev, 2*MBX_SIZE(i), &mbx_dma);
>
> you might want a pci_set_dma_mask(,DMA_32BIT_MASK) before you call this.
That's the default, no need.
^ permalink raw reply
* Re: [PATCH] reduce netfilte sk_buff enlargement
From: David S. Miller @ 2005-07-20 18:43 UTC (permalink / raw)
To: laforge; +Cc: netdev, marcel, netfilter-devel, wensong
In-Reply-To: <20050720132305.GA4077@rama>
From: Harald Welte <laforge@netfilter.org>
Date: Wed, 20 Jul 2005 09:23:05 -0400
> On Mon, Jul 18, 2005 at 08:31:45PM -0700, David S. Miller wrote:
> > From: Harald Welte <laforge@netfilter.org>
> > Date: Mon, 18 Jul 2005 00:04:51 +0200
> >
> > > The only real in-tree user of nfcache was IPVS, who only needs a single
> > > bit. Unfortunately I couldn't find some other free bit in sk_buff to
> > > stuff that bit into, so I introduced a separate field for them. Maybe
> > > the IPVS guys can resolve that to further save space.
> >
> > I think we must resolve this one before 2.6.14 goes out, which
> > gives us a lot of time, but for now I'll eat that one-bit member.
>
> Well, I hope IPVS people will take care of this. I don't really know
> that code too well...
Ok, I might take a look at this myself.
> > > Initially I wanted to shrink pkt_type to three bits (PACKET_HOST and
> > > alike are only 6 values defined), but unfortunately the bluetooth code
> > > overloads pkt_type :(
> >
> > This also must be cured somehow, that really isn't a clean nor nice
> > usage of this field.
>
> I just ran into Marcel Holtmann earlier today. He thinks moving that
> data into the cb is fine, though he has to double-check that.
>
> He also said that he really only needs 5 bits, so even if the current
> pkt_type overloading would persist, we could probably shrink it to make
> space for the IPVS bit.
Ok, sounds great.
^ permalink raw reply
* Seeing problem on 2.6.13-rc3
From: Ravinandan Arakali @ 2005-07-20 17:04 UTC (permalink / raw)
To: netdev; +Cc: Leonid. Grossman (E-mail), Raghavendra. Koushik (E-mail)
Hi,
I am facing the following problem with loading S2io 10GbE driver on
2.6.13-rc3.
Just wondering if anybody else is having similar problems with S2io
driver or other drivers.
When trying to load s2io driver, I see the following message:
eth%d: 1:Endian settings are wrong, feedback read ffffffffffffffff
eth%d:swapper settings are wrong
Basically, we try to configure the card for correct access on
both endian systems. This seems to fail.
But on a somewhat similar kernel(2.6.13-rc2-mm2), with the same
system, card and driver, it works fine.
Thanks,
Ravi
^ permalink raw reply
* Re: [PATCH] reduce netfilte sk_buff enlargement
From: Wensong Zhang @ 2005-07-20 15:43 UTC (permalink / raw)
To: Harald Welte; +Cc: netdev, Marcel Holtmann, netfilter-devel
In-Reply-To: <20050720132305.GA4077@rama>
Hi,
Sorry for the delay.
On Wed, 20 Jul 2005, Harald Welte wrote:
> On Mon, Jul 18, 2005 at 08:31:45PM -0700, David S. Miller wrote:
>> From: Harald Welte <laforge@netfilter.org>
>> Date: Mon, 18 Jul 2005 00:04:51 +0200
>>
>>> The only real in-tree user of nfcache was IPVS, who only needs a single
>>> bit. Unfortunately I couldn't find some other free bit in sk_buff to
>>> stuff that bit into, so I introduced a separate field for them. Maybe
>>> the IPVS guys can resolve that to further save space.
>>
>> I think we must resolve this one before 2.6.14 goes out, which
>> gives us a lot of time, but for now I'll eat that one-bit member.
>
> Well, I hope IPVS people will take care of this. I don't really know
> that code too well...
>
This bit is only to indicate that the sk_buff is already mangled by
IPVS/NAT, so that when both iptables/NAT and IPVS/NAT are enabled,
iptables/NAT will not mangle sk_buff again. I am not sure if there is more
elegant way to work around this issue, will investigate it.
>>> Initially I wanted to shrink pkt_type to three bits (PACKET_HOST and
>>> alike are only 6 values defined), but unfortunately the bluetooth code
>>> overloads pkt_type :(
>>
>> This also must be cured somehow, that really isn't a clean nor nice
>> usage of this field.
>
> I just ran into Marcel Holtmann earlier today. He thinks moving that
> data into the cb is fine, though he has to double-check that.
>
> He also said that he really only needs 5 bits, so even if the current
> pkt_type overloading would persist, we could probably shrink it to make
> space for the IPVS bit.
>
That's cool.
Thanks,
Wensong
^ permalink raw reply
* Re: [patch linux-2.6.13-rc2-gitXX 1/1] zatm: mailbox converted to pci_alloc_consistent()
From: chas @ 2005-07-20 15:07 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev
In-Reply-To: <20050719223655.GA27724@electric-eye.fr.zoreil.com>
In message <20050719223655.GA27724@electric-eye.fr.zoreil.com>,Francois Romieu
writes:
>+ mbx = pci_alloc_consistent(pdev, 2*MBX_SIZE(i), &mbx_dma);
you might want a pci_set_dma_mask(,DMA_32BIT_MASK) before you call this.
^ permalink raw reply
* [PATCH 3/*] re-add NFC_ defines
From: Harald Welte @ 2005-07-20 13:31 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List, Netfilter Development Mailinglist
[-- Attachment #1.1: Type: text/plain, Size: 592 bytes --]
Hi Dave,
we have to re-add the NFC_ defines to the header files, otherwise old
userspace code (such as old versions of the iptables program) will fail
to compile :(
Please apply to your 2.6.14 tree, thanks!
--
- Harald Welte <laforge@netfilter.org> http://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 #1.2: 03-nfc_defines.patch --]
[-- Type: text/plain, Size: 4433 bytes --]
re-add NFC_* defines, since old usersapce programs need those definitions.
So we'll have to keep them, even if they're totally useless.
They're now in an "#ifndef __KERNEL__" section though.
Signed-off-by: Harald Welte <laforge@netfilter.org>
---
commit 2e301df4f0b9c9c0faf68e5b42d2f59d912c148f
tree 0aa034b16808c0eb13ea49d31c268d5d9a70f4d1
parent 41a00086e4c896f92c8a29f8e2e5f6d893118e77
author laforge <laforge@netfilter.org> Mi, 20 Jul 2005 09:15:03 -0400
committer laforge <laforge@netfilter.org> Mi, 20 Jul 2005 09:15:03 -0400
include/linux/netfilter.h | 8 ++++++++
include/linux/netfilter_decnet.h | 13 +++++++++++++
include/linux/netfilter_ipv4.h | 31 +++++++++++++++++++++++++++++++
include/linux/netfilter_ipv6.h | 33 +++++++++++++++++++++++++++++++++
4 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -21,6 +21,14 @@
#define NF_STOP 5
#define NF_MAX_VERDICT NF_STOP
+/* only for userspace compatibility */
+#ifndef __KERNEL__
+/* Generic cache responses from hook functions.
+ <= 0x2000 is used for protocol-flags. */
+#define NFC_UNKNOWN 0x4000
+#define NFC_ALTERED 0x8000
+#endif
+
#ifdef __KERNEL__
#include <linux/config.h>
#ifdef CONFIG_NETFILTER
diff --git a/include/linux/netfilter_decnet.h b/include/linux/netfilter_decnet.h
--- a/include/linux/netfilter_decnet.h
+++ b/include/linux/netfilter_decnet.h
@@ -9,6 +9,19 @@
#include <linux/netfilter.h>
+/* only for userspace compatibility */
+#ifndef __KERNEL__
+/* IP Cache bits. */
+/* Src IP address. */
+#define NFC_DN_SRC 0x0001
+/* Dest IP address. */
+#define NFC_DN_DST 0x0002
+/* Input device. */
+#define NFC_DN_IF_IN 0x0004
+/* Output device. */
+#define NFC_DN_IF_OUT 0x0008
+#endif /* ! __KERNEL__ */
+
/* DECnet Hooks */
/* After promisc drops, checksum checks. */
#define NF_DN_PRE_ROUTING 0
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -8,6 +8,37 @@
#include <linux/config.h>
#include <linux/netfilter.h>
+/* only for userspace compatibility */
+#ifndef __KERNEL__
+/* IP Cache bits. */
+/* Src IP address. */
+#define NFC_IP_SRC 0x0001
+/* Dest IP address. */
+#define NFC_IP_DST 0x0002
+/* Input device. */
+#define NFC_IP_IF_IN 0x0004
+/* Output device. */
+#define NFC_IP_IF_OUT 0x0008
+/* TOS. */
+#define NFC_IP_TOS 0x0010
+/* Protocol. */
+#define NFC_IP_PROTO 0x0020
+/* IP options. */
+#define NFC_IP_OPTIONS 0x0040
+/* Frag & flags. */
+#define NFC_IP_FRAG 0x0080
+
+/* Per-protocol information: only matters if proto match. */
+/* TCP flags. */
+#define NFC_IP_TCPFLAGS 0x0100
+/* Source port. */
+#define NFC_IP_SRC_PT 0x0200
+/* Dest port. */
+#define NFC_IP_DST_PT 0x0400
+/* Something else about the proto */
+#define NFC_IP_PROTO_UNKNOWN 0x2000
+#endif /* ! __KERNEL__ */
+
/* IP Hooks */
/* After promisc drops, checksum checks. */
#define NF_IP_PRE_ROUTING 0
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
--- a/include/linux/netfilter_ipv6.h
+++ b/include/linux/netfilter_ipv6.h
@@ -10,6 +10,39 @@
#include <linux/netfilter.h>
+/* only for userspace compatibility */
+#ifndef __KERNEL__
+/* IP Cache bits. */
+/* Src IP address. */
+#define NFC_IP6_SRC 0x0001
+/* Dest IP address. */
+#define NFC_IP6_DST 0x0002
+/* Input device. */
+#define NFC_IP6_IF_IN 0x0004
+/* Output device. */
+#define NFC_IP6_IF_OUT 0x0008
+/* TOS. */
+#define NFC_IP6_TOS 0x0010
+/* Protocol. */
+#define NFC_IP6_PROTO 0x0020
+/* IP options. */
+#define NFC_IP6_OPTIONS 0x0040
+/* Frag & flags. */
+#define NFC_IP6_FRAG 0x0080
+
+
+/* Per-protocol information: only matters if proto match. */
+/* TCP flags. */
+#define NFC_IP6_TCPFLAGS 0x0100
+/* Source port. */
+#define NFC_IP6_SRC_PT 0x0200
+/* Dest port. */
+#define NFC_IP6_DST_PT 0x0400
+/* Something else about the proto */
+#define NFC_IP6_PROTO_UNKNOWN 0x2000
+#endif /* ! __KERNEL__ */
+
+
/* IP6 Hooks */
/* After promisc drops, checksum checks. */
#define NF_IP6_PRE_ROUTING 0
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH 2/*] nfnetlink layer
From: Harald Welte @ 2005-07-20 13:30 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List, Netfilter Development Mailinglist
[-- Attachment #1.1: Type: text/plain, Size: 553 bytes --]
Hi Dave,
here comes the nfnetlink layer. Its first user (ctnetlink) is waiting
for some last review and will follow tomorrow.
Please apply to your 2.6.14 tree, thanks!
--
- Harald Welte <laforge@netfilter.org> http://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 #1.2: 02-nfnetlink.patch --]
[-- Type: text/plain, Size: 15957 bytes --]
Introduce "nfnetlink" (netfilter netlink) layer. This layer is used as
transport layer for all userspace communication of the new upcoming
netfilter subsystems, such as ctnetlink, nfnetlink_queue and some day even
the mythical pkttables ;)
Signed-off-by: Harald Welte <laforge@netfilter.org>
---
commit 41a00086e4c896f92c8a29f8e2e5f6d893118e77
tree db282fb2ed082b8a1b70b0c5bdf87928da6c594f
parent 212c12f0005581d2625a1bd0add59cd8ac5725d0
author laforge <laforge@netfilter.org> Mi, 20 Jul 2005 09:02:40 -0400
committer laforge <laforge@netfilter.org> Mi, 20 Jul 2005 09:02:40 -0400
include/linux/netfilter/nfnetlink.h | 145 +++++++++++++++
net/Kconfig | 2
net/Makefile | 1
net/netfilter/Kconfig | 5 +
net/netfilter/Makefile | 1
net/netfilter/nfnetlink.c | 343 +++++++++++++++++++++++++++++++++++
6 files changed, 497 insertions(+), 0 deletions(-)
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
new file mode 100644
--- /dev/null
+++ b/include/linux/netfilter/nfnetlink.h
@@ -0,0 +1,145 @@
+#ifndef _NFNETLINK_H
+#define _NFNETLINK_H
+#include <linux/types.h>
+
+/* nfnetlink groups: Up to 32 maximum */
+#define NF_NETLINK_CONNTRACK_NEW 0x00000001
+#define NF_NETLINK_CONNTRACK_UPDATE 0x00000002
+#define NF_NETLINK_CONNTRACK_DESTROY 0x00000004
+#define NF_NETLINK_CONNTRACK_EXP_NEW 0x00000008
+#define NF_NETLINK_CONNTRACK_EXP_UPDATE 0x00000010
+#define NF_NETLINK_CONNTRACK_EXP_DESTROY 0x00000020
+
+/* Generic structure for encapsulation optional netfilter information.
+ * It is reminiscent of sockaddr, but with sa_family replaced
+ * with attribute type.
+ * ! This should someday be put somewhere generic as now rtnetlink and
+ * ! nfnetlink use the same attributes methods. - J. Schulist.
+ */
+
+struct nfattr
+{
+ u_int16_t nfa_len;
+ u_int16_t nfa_type;
+} __attribute__ ((packed));
+
+/* FIXME: Shamelessly copy and pasted from rtnetlink.h, it's time
+ * to put this in a generic file */
+
+#define NFA_ALIGNTO 4
+#define NFA_ALIGN(len) (((len) + NFA_ALIGNTO - 1) & ~(NFA_ALIGNTO - 1))
+#define NFA_OK(nfa,len) ((len) > 0 && (nfa)->nfa_len >= sizeof(struct nfattr) \
+ && (nfa)->nfa_len <= (len))
+#define NFA_NEXT(nfa,attrlen) ((attrlen) -= NFA_ALIGN((nfa)->nfa_len), \
+ (struct nfattr *)(((char *)(nfa)) + NFA_ALIGN((nfa)->nfa_len)))
+#define NFA_LENGTH(len) (NFA_ALIGN(sizeof(struct nfattr)) + (len))
+#define NFA_SPACE(len) NFA_ALIGN(NFA_LENGTH(len))
+#define NFA_DATA(nfa) ((void *)(((char *)(nfa)) + NFA_LENGTH(0)))
+#define NFA_PAYLOAD(nfa) ((int)((nfa)->nfa_len) - NFA_LENGTH(0))
+#define NFA_NEST(skb, type) \
+({ struct nfattr *__start = (struct nfattr *) (skb)->tail; \
+ NFA_PUT(skb, type, 0, NULL); \
+ __start; })
+#define NFA_NEST_END(skb, start) \
+({ (start)->nfa_len = ((skb)->tail - (unsigned char *) (start)); \
+ (skb)->len; })
+#define NFA_NEST_CANCEL(skb, start) \
+({ if (start) \
+ skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
+ -1; })
+
+/* General form of address family dependent message.
+ */
+struct nfgenmsg {
+ u_int8_t nfgen_family; /* AF_xxx */
+ u_int8_t version; /* nfnetlink version */
+ u_int16_t res_id; /* resource id */
+} __attribute__ ((packed));
+
+#define NFNETLINK_V1 1
+
+#define NFM_NFA(n) ((struct nfattr *)(((char *)(n)) \
+ + NLMSG_ALIGN(sizeof(struct nfgenmsg))))
+#define NFM_PAYLOAD(n) NLMSG_PAYLOAD(n, sizeof(struct nfgenmsg))
+
+/* netfilter netlink message types are split in two pieces:
+ * 8 bit subsystem, 8bit operation.
+ */
+
+#define NFNL_SUBSYS_ID(x) ((x & 0xff00) >> 8)
+#define NFNL_MSG_TYPE(x) (x & 0x00ff)
+
+enum nfnl_subsys_id {
+ NFNL_SUBSYS_NONE = 0,
+ NFNL_SUBSYS_CTNETLINK,
+ NFNL_SUBSYS_CTNETLINK_EXP,
+ NFNL_SUBSYS_IPTNETLINK,
+ NFNL_SUBSYS_QUEUE,
+ NFNL_SUBSYS_ULOG,
+ NFNL_SUBSYS_COUNT,
+};
+
+#ifdef __KERNEL__
+
+#include <linux/capability.h>
+
+struct nfnl_callback
+{
+ kernel_cap_t cap_required; /* capabilities required for this msg */
+ int (*call)(struct sock *nl, struct sk_buff *skb,
+ struct nlmsghdr *nlh, struct nfattr *cda[], int *errp);
+};
+
+struct nfnetlink_subsystem
+{
+ const char *name;
+ __u8 subsys_id; /* nfnetlink subsystem ID */
+ __u8 cb_count; /* number of callbacks */
+ u_int32_t attr_count; /* number of nfattr's */
+ struct nfnl_callback *cb; /* callback for individual types */
+};
+
+extern void __nfa_fill(struct sk_buff *skb, int attrtype,
+ int attrlen, const void *data);
+#define NFA_PUT(skb, attrtype, attrlen, data) \
+({ if (skb_tailroom(skb) < (int)NFA_SPACE(attrlen)) goto nfattr_failure; \
+ __nfa_fill(skb, attrtype, attrlen, data); })
+
+extern struct semaphore nfnl_sem;
+
+#define nfnl_shlock() down(&nfnl_sem)
+#define nfnl_shlock_nowait() down_trylock(&nfnl_sem)
+
+#define nfnl_shunlock() do { up(&nfnl_sem); \
+ if(nfnl && nfnl->sk_receive_queue.qlen) \
+ nfnl->sk_data_ready(nfnl, 0); \
+ } while(0)
+
+extern void nfnl_lock(void);
+extern void nfnl_unlock(void);
+
+extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n);
+extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n);
+
+extern int nfattr_parse(struct nfattr *tb[], int maxattr,
+ struct nfattr *nfa, int len);
+
+#define nfattr_parse_nested(tb, max, nfa) \
+ nfattr_parse((tb), (max), NFA_DATA((nfa)), NFA_PAYLOAD((nfa)))
+
+#define nfattr_bad_size(tb, max, cta_min) \
+({ int __i, __res = 0; \
+ for (__i=0; __i<max; __i++) \
+ if (tb[__i] && NFA_PAYLOAD(tb[__i]) < cta_min[__i]){ \
+ __res = 1; \
+ break; \
+ } \
+ __res; \
+})
+
+extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group,
+ int echo);
+extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
+
+#endif /* __KERNEL__ */
+#endif /* _NFNETLINK_H */
diff --git a/net/Kconfig b/net/Kconfig
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -205,6 +205,8 @@ config NET_PKTGEN
To compile this code as a module, choose M here: the
module will be called pktgen.
+source "net/netfilter/Kconfig"
+
endmenu
endmenu
diff --git a/net/Makefile b/net/Makefile
--- a/net/Makefile
+++ b/net/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_NET) += $(tmp-y)
obj-$(CONFIG_LLC) += llc/
obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/
obj-$(CONFIG_INET) += ipv4/
+obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_XFRM) += xfrm/
obj-$(CONFIG_UNIX) += unix/
ifneq ($(CONFIG_IPV6),)
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
new file mode 100644
--- /dev/null
+++ b/net/netfilter/Kconfig
@@ -0,0 +1,5 @@
+config NETFILTER_NETLINK
+ tristate "Netfilter netlink interface"
+ help
+ If this option is enabled, the kernel will include support
+ for the new netfilter netlink interface.
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
new file mode 100644
--- /dev/null
+++ b/net/netfilter/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_NETFILTER_NETLINK) += nfnetlink.o
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
new file mode 100644
--- /dev/null
+++ b/net/netfilter/nfnetlink.c
@@ -0,0 +1,343 @@
+/* Netfilter messages via netlink socket. Allows for user space
+ * protocol helpers and general trouble making from userspace.
+ *
+ * (C) 2001 by Jay Schulist <jschlst@samba.org>,
+ * (C) 2002-2005 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net>
+ *
+ * Initial netfilter messages via netlink development funded and
+ * generally made possible by Network Robots, Inc. (www.networkrobots.com)
+ *
+ * Further development of this code funded by Astaro AG (http://www.astaro.com)
+ *
+ * This software may be used and distributed according to the terms
+ * of the GNU General Public License, incorporated herein by reference.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/socket.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/string.h>
+#include <linux/sockios.h>
+#include <linux/net.h>
+#include <linux/fcntl.h>
+#include <linux/skbuff.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <net/sock.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+
+#include <linux/netfilter.h>
+#include <linux/netlink.h>
+#include <linux/netfilter/nfnetlink.h>
+
+MODULE_LICENSE("GPL");
+
+static char __initdata nfversion[] = "0.30";
+
+#if 0
+#define DEBUGP printk
+#else
+#define DEBUGP(format, args...)
+#endif
+
+static struct sock *nfnl = NULL;
+static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT];
+DECLARE_MUTEX(nfnl_sem);
+
+void nfnl_lock(void)
+{
+ nfnl_shlock();
+}
+
+void nfnl_unlock(void)
+{
+ nfnl_shunlock();
+}
+
+int nfnetlink_subsys_register(struct nfnetlink_subsystem *n)
+{
+ DEBUGP("registering subsystem ID %u\n", n->subsys_id);
+
+ /* If the netlink socket wasn't created, then fail */
+ if (!nfnl)
+ return -1;
+
+ nfnl_lock();
+ subsys_table[n->subsys_id] = n;
+ nfnl_unlock();
+
+ return 0;
+}
+
+int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n)
+{
+ DEBUGP("unregistering subsystem ID %u\n", n->subsys_id);
+
+ nfnl_lock();
+ subsys_table[n->subsys_id] = NULL;
+ nfnl_unlock();
+
+ return 0;
+}
+
+static inline struct nfnetlink_subsystem *nfnetlink_get_subsys(u_int16_t type)
+{
+ u_int8_t subsys_id = NFNL_SUBSYS_ID(type);
+
+ if (subsys_id >= NFNL_SUBSYS_COUNT
+ || subsys_table[subsys_id] == NULL)
+ return NULL;
+
+ return subsys_table[subsys_id];
+}
+
+static inline struct nfnl_callback *
+nfnetlink_find_client(u_int16_t type, struct nfnetlink_subsystem *ss)
+{
+ u_int8_t cb_id = NFNL_MSG_TYPE(type);
+
+ if (cb_id >= ss->cb_count) {
+ DEBUGP("msgtype %u >= %u, returning\n", type, ss->cb_count);
+ return NULL;
+ }
+
+ return &ss->cb[cb_id];
+}
+
+void __nfa_fill(struct sk_buff *skb, int attrtype, int attrlen,
+ const void *data)
+{
+ struct nfattr *nfa;
+ int size = NFA_LENGTH(attrlen);
+
+ nfa = (struct nfattr *)skb_put(skb, NFA_ALIGN(size));
+ nfa->nfa_type = attrtype;
+ nfa->nfa_len = size;
+ memcpy(NFA_DATA(nfa), data, attrlen);
+}
+
+int nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
+{
+ memset(tb, 0, sizeof(struct nfattr *) * maxattr);
+
+ while (NFA_OK(nfa, len)) {
+ unsigned flavor = nfa->nfa_type;
+ if (flavor && flavor <= maxattr)
+ tb[flavor-1] = nfa;
+ nfa = NFA_NEXT(nfa, len);
+ }
+
+ return 0;
+}
+
+/**
+ * nfnetlink_check_attributes - check and parse nfnetlink attributes
+ *
+ * subsys: nfnl subsystem for which this message is to be parsed
+ * nlmsghdr: netlink message to be checked/parsed
+ * cda: array of pointers, needs to be at least subsys->attr_count big
+ *
+ */
+static int
+nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
+ struct nlmsghdr *nlh, struct nfattr *cda[])
+{
+ int min_len;
+
+ memset(cda, 0, sizeof(struct nfattr *) * subsys->attr_count);
+
+ /* check attribute lengths. */
+ min_len = NLMSG_ALIGN(sizeof(struct nfgenmsg));
+ if (nlh->nlmsg_len < min_len)
+ return -EINVAL;
+
+ if (nlh->nlmsg_len > min_len) {
+ struct nfattr *attr = NFM_NFA(NLMSG_DATA(nlh));
+ int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
+
+ while (NFA_OK(attr, attrlen)) {
+ unsigned flavor = attr->nfa_type;
+ if (flavor) {
+ if (flavor > subsys->attr_count)
+ return -EINVAL;
+ cda[flavor - 1] = attr;
+ }
+ attr = NFA_NEXT(attr, attrlen);
+ }
+ } else
+ return -EINVAL;
+
+ return 0;
+}
+
+int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
+{
+ int allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
+ int err = 0;
+
+ NETLINK_CB(skb).dst_groups = group;
+ if (echo)
+ atomic_inc(&skb->users);
+ netlink_broadcast(nfnl, skb, pid, group, allocation);
+ if (echo)
+ err = netlink_unicast(nfnl, skb, pid, MSG_DONTWAIT);
+
+ return err;
+}
+
+int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags)
+{
+ return netlink_unicast(nfnl, skb, pid, flags);
+}
+
+/* Process one complete nfnetlink message. */
+static inline int nfnetlink_rcv_msg(struct sk_buff *skb,
+ struct nlmsghdr *nlh, int *errp)
+{
+ struct nfnl_callback *nc;
+ struct nfnetlink_subsystem *ss;
+ int type, err = 0;
+
+ DEBUGP("entered; subsys=%u, msgtype=%u\n",
+ NFNL_SUBSYS_ID(nlh->nlmsg_type),
+ NFNL_MSG_TYPE(nlh->nlmsg_type));
+
+ /* Only requests are handled by kernel now. */
+ if (!(nlh->nlmsg_flags & NLM_F_REQUEST)) {
+ DEBUGP("received non-request message\n");
+ return 0;
+ }
+
+ /* All the messages must at least contain nfgenmsg */
+ if (nlh->nlmsg_len <
+ NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg)))) {
+ DEBUGP("received message was too short\n");
+ return 0;
+ }
+
+ type = nlh->nlmsg_type;
+ ss = nfnetlink_get_subsys(type);
+ if (!ss)
+ goto err_inval;
+
+ nc = nfnetlink_find_client(type, ss);
+ if (!nc) {
+ DEBUGP("unable to find client for type %d\n", type);
+ goto err_inval;
+ }
+
+ if (nc->cap_required &&
+ !cap_raised(NETLINK_CB(skb).eff_cap, nc->cap_required)) {
+ DEBUGP("permission denied for type %d\n", type);
+ *errp = -EPERM;
+ return -1;
+ }
+
+ {
+ struct nfattr *cda[ss->attr_count];
+
+ memset(cda, 0, ss->attr_count*sizeof(struct nfattr *));
+
+ err = nfnetlink_check_attributes(ss, nlh, cda);
+ if (err < 0)
+ goto err_inval;
+
+ err = nc->call(nfnl, skb, nlh, cda, errp);
+ *errp = err;
+ return err;
+ }
+
+err_inval:
+ *errp = -EINVAL;
+ return -1;
+}
+
+/* Process one packet of messages. */
+static inline int nfnetlink_rcv_skb(struct sk_buff *skb)
+{
+ int err;
+ struct nlmsghdr *nlh;
+
+ while (skb->len >= NLMSG_SPACE(0)) {
+ u32 rlen;
+
+ nlh = (struct nlmsghdr *)skb->data;
+ if (nlh->nlmsg_len < sizeof(struct nlmsghdr)
+ || skb->len < nlh->nlmsg_len)
+ return 0;
+ rlen = NLMSG_ALIGN(nlh->nlmsg_len);
+ if (rlen > skb->len)
+ rlen = skb->len;
+ if (nfnetlink_rcv_msg(skb, nlh, &err)) {
+ if (!err)
+ return -1;
+ netlink_ack(skb, nlh, err);
+ } else
+ if (nlh->nlmsg_flags & NLM_F_ACK)
+ netlink_ack(skb, nlh, 0);
+ skb_pull(skb, rlen);
+ }
+
+ return 0;
+}
+
+static void nfnetlink_rcv(struct sock *sk, int len)
+{
+ do {
+ struct sk_buff *skb;
+
+ if (nfnl_shlock_nowait())
+ return;
+
+ while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
+ if (nfnetlink_rcv_skb(skb)) {
+ if (skb->len)
+ skb_queue_head(&sk->sk_receive_queue,
+ skb);
+ else
+ kfree_skb(skb);
+ break;
+ }
+ kfree_skb(skb);
+ }
+
+ up(&nfnl_sem);
+ } while(nfnl && nfnl->sk_receive_queue.qlen);
+}
+
+void __exit nfnetlink_exit(void)
+{
+ printk("Removing netfilter NETLINK layer.\n");
+ sock_release(nfnl->sk_socket);
+ return;
+}
+
+int __init nfnetlink_init(void)
+{
+ printk("Netfilter messages via NETLINK v%s.\n", nfversion);
+
+ nfnl = netlink_kernel_create(NETLINK_NETFILTER, nfnetlink_rcv);
+ if (!nfnl) {
+ printk(KERN_ERR "cannot initialize nfnetlink!\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+module_init(nfnetlink_init);
+module_exit(nfnetlink_exit);
+
+EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
+EXPORT_SYMBOL_GPL(nfnetlink_subsys_unregister);
+EXPORT_SYMBOL_GPL(nfnetlink_send);
+EXPORT_SYMBOL_GPL(nfnetlink_unicast);
+EXPORT_SYMBOL_GPL(nfattr_parse);
+EXPORT_SYMBOL_GPL(__nfa_fill);
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH 1/*] connection tracking event notifiers
From: Harald Welte @ 2005-07-20 13:27 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List, Netfilter Development Mailinglist
[-- Attachment #1.1: Type: text/plain, Size: 666 bytes --]
Hi Dave,
I'm now starting to send the accumulated netfilter patches. For now
there will be three (event notifiers, nfnetlink, nfc_defines). Tomorrow
some more (ctnetlink, with some luck nfnetlink_queue and the
pptp-helper) will follow.
Please apply to your 2.6.14 tree, thanks!
--
- Harald Welte <laforge@netfilter.org> http://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 #1.2: 01-ctevent.patch --]
[-- Type: text/plain, Size: 20545 bytes --]
This adds a notifier chain based event mechanism for ip_conntrack state
changes. As opposed to the previous implementations in patch-o-matic, we
do no longer need a field in the skb to achieve this.
Thanks to the valuable input from Patrick McHardy and Rusty on the idea
of a per_cpu implementation.
Signed-off-by: Harald Welte <laforge@netfilter.org>
---
commit 212c12f0005581d2625a1bd0add59cd8ac5725d0
tree d713bb281f89f966c2d5b26b76b803f83ce40ae7
parent 952afcc6bee0883be51320865d8848dace060603
author laforge <laforge@netfilter.org> Mi, 20 Jul 2005 08:49:13 -0400
committer laforge <laforge@netfilter.org> Mi, 20 Jul 2005 08:49:13 -0400
include/linux/netfilter_ipv4/ip_conntrack.h | 144 ++++++++++++++++++++++
include/linux/netfilter_ipv4/ip_conntrack_core.h | 17 ++-
net/ipv4/netfilter/Kconfig | 10 ++
net/ipv4/netfilter/ip_conntrack_core.c | 122 ++++++++++++++++++-
net/ipv4/netfilter/ip_conntrack_ftp.c | 12 +-
net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 1
net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 2
net/ipv4/netfilter/ip_conntrack_proto_tcp.c | 4 +
net/ipv4/netfilter/ip_conntrack_proto_udp.c | 3
net/ipv4/netfilter/ip_conntrack_standalone.c | 10 ++
10 files changed, 311 insertions(+), 14 deletions(-)
diff --git a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
--- a/include/linux/netfilter_ipv4/ip_conntrack.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -65,6 +65,63 @@ enum ip_conntrack_status {
/* Both together */
IPS_NAT_DONE_MASK = (IPS_DST_NAT_DONE | IPS_SRC_NAT_DONE),
+
+ /* Connection is dying (removed from lists), can not be unset. */
+ IPS_DYING_BIT = 9,
+ IPS_DYING = (1 << IPS_DYING_BIT),
+};
+
+/* Connection tracking event bits */
+enum ip_conntrack_events
+{
+ /* New conntrack */
+ IPCT_NEW_BIT = 0,
+ IPCT_NEW = (1 << IPCT_NEW_BIT),
+
+ /* Expected connection */
+ IPCT_RELATED_BIT = 1,
+ IPCT_RELATED = (1 << IPCT_RELATED_BIT),
+
+ /* Destroyed conntrack */
+ IPCT_DESTROY_BIT = 2,
+ IPCT_DESTROY = (1 << IPCT_DESTROY_BIT),
+
+ /* Timer has been refreshed */
+ IPCT_REFRESH_BIT = 3,
+ IPCT_REFRESH = (1 << IPCT_REFRESH_BIT),
+
+ /* Status has changed */
+ IPCT_STATUS_BIT = 4,
+ IPCT_STATUS = (1 << IPCT_STATUS_BIT),
+
+ /* Update of protocol info */
+ IPCT_PROTOINFO_BIT = 5,
+ IPCT_PROTOINFO = (1 << IPCT_PROTOINFO_BIT),
+
+ /* Volatile protocol info */
+ IPCT_PROTOINFO_VOLATILE_BIT = 6,
+ IPCT_PROTOINFO_VOLATILE = (1 << IPCT_PROTOINFO_VOLATILE_BIT),
+
+ /* New helper for conntrack */
+ IPCT_HELPER_BIT = 7,
+ IPCT_HELPER = (1 << IPCT_HELPER_BIT),
+
+ /* Update of helper info */
+ IPCT_HELPINFO_BIT = 8,
+ IPCT_HELPINFO = (1 << IPCT_HELPINFO_BIT),
+
+ /* Volatile helper info */
+ IPCT_HELPINFO_VOLATILE_BIT = 9,
+ IPCT_HELPINFO_VOLATILE = (1 << IPCT_HELPINFO_VOLATILE_BIT),
+
+ /* NAT info */
+ IPCT_NATINFO_BIT = 10,
+ IPCT_NATINFO = (1 << IPCT_NATINFO_BIT),
+};
+
+enum ip_conntrack_expect_events {
+ IPEXP_NEW_BIT = 0,
+ IPEXP_NEW = (1 << IPEXP_NEW_BIT),
};
#ifdef __KERNEL__
@@ -277,6 +334,11 @@ static inline int is_confirmed(struct ip
return test_bit(IPS_CONFIRMED_BIT, &ct->status);
}
+static inline int is_dying(struct ip_conntrack *ct)
+{
+ return test_bit(IPS_DYING_BIT, &ct->status);
+}
+
extern unsigned int ip_conntrack_htable_size;
struct ip_conntrack_stat
@@ -300,6 +362,88 @@ struct ip_conntrack_stat
#define CONNTRACK_STAT_INC(count) (__get_cpu_var(ip_conntrack_stat).count++)
+#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
+#include <linux/notifier.h>
+
+struct ip_conntrack_ecache {
+ struct ip_conntrack *ct;
+ unsigned int events;
+};
+DECLARE_PER_CPU(struct ip_conntrack_ecache, ip_conntrack_ecache);
+
+#define CONNTRACK_ECACHE(x) (__get_cpu_var(ip_conntrack_ecache).x)
+
+extern struct notifier_block *ip_conntrack_chain;
+extern struct notifier_block *ip_conntrack_expect_chain;
+
+static inline int ip_conntrack_register_notifier(struct notifier_block *nb)
+{
+ return notifier_chain_register(&ip_conntrack_chain, nb);
+}
+
+static inline int ip_conntrack_unregister_notifier(struct notifier_block *nb)
+{
+ return notifier_chain_unregister(&ip_conntrack_chain, nb);
+}
+
+static inline int
+ip_conntrack_expect_register_notifier(struct notifier_block *nb)
+{
+ return notifier_chain_register(&ip_conntrack_expect_chain, nb);
+}
+
+static inline int
+ip_conntrack_expect_unregister_notifier(struct notifier_block *nb)
+{
+ return notifier_chain_unregister(&ip_conntrack_expect_chain, nb);
+}
+
+static inline void
+ip_conntrack_event_cache(enum ip_conntrack_events event,
+ const struct sk_buff *skb)
+{
+ struct ip_conntrack_ecache *ecache =
+ &__get_cpu_var(ip_conntrack_ecache);
+
+ if (unlikely((struct ip_conntrack *) skb->nfct != ecache->ct)) {
+ if (net_ratelimit()) {
+ printk(KERN_ERR "ctevent: skb->ct != ecache->ct !!!\n");
+ dump_stack();
+ }
+ }
+ ecache->events |= event;
+}
+
+extern void
+ip_conntrack_deliver_cached_events_for(const struct ip_conntrack *ct);
+extern void ip_conntrack_event_cache_init(const struct sk_buff *skb);
+
+static inline void ip_conntrack_event(enum ip_conntrack_events event,
+ struct ip_conntrack *ct)
+{
+ if (is_confirmed(ct) && !is_dying(ct))
+ notifier_call_chain(&ip_conntrack_chain, event, ct);
+}
+
+static inline void
+ip_conntrack_expect_event(enum ip_conntrack_expect_events event,
+ struct ip_conntrack_expect *exp)
+{
+ notifier_call_chain(&ip_conntrack_expect_chain, event, exp);
+}
+#else /* CONFIG_IP_NF_CONNTRACK_EVENTS */
+static inline void ip_conntrack_event_cache(enum ip_conntrack_events event,
+ const struct sk_buff *skb) {}
+static inline void ip_conntrack_event(enum ip_conntrack_events event,
+ struct ip_conntrack *ct) {}
+static inline void ip_conntrack_deliver_cached_events_for(
+ struct ip_conntrack *ct) {}
+static inline void ip_conntrack_event_cache_init(const struct sk_buff *skb) {}
+static inline void
+ip_conntrack_expect_event(enum ip_conntrack_expect_events event,
+ struct ip_conntrack_expect *exp) {}
+#endif /* CONFIG_IP_NF_CONNTRACK_EVENTS */
+
#ifdef CONFIG_IP_NF_NAT_NEEDED
static inline int ip_nat_initialized(struct ip_conntrack *conntrack,
enum ip_nat_manip_type manip)
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_core.h b/include/linux/netfilter_ipv4/ip_conntrack_core.h
--- a/include/linux/netfilter_ipv4/ip_conntrack_core.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_core.h
@@ -38,12 +38,21 @@ extern int __ip_conntrack_confirm(struct
/* Confirm a connection: returns NF_DROP if packet must be dropped. */
static inline int ip_conntrack_confirm(struct sk_buff **pskb)
{
- if ((*pskb)->nfct
- && !is_confirmed((struct ip_conntrack *)(*pskb)->nfct))
- return __ip_conntrack_confirm(pskb);
- return NF_ACCEPT;
+ struct ip_conntrack *ct = (struct ip_conntrack *)(*pskb)->nfct;
+ int ret = NF_ACCEPT;
+
+ if (ct && !is_confirmed(ct))
+ ret = __ip_conntrack_confirm(pskb);
+ ip_conntrack_deliver_cached_events_for(ct);
+
+ return ret;
}
+#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
+struct ip_conntrack_ecache;
+extern void __ip_ct_deliver_cached_events(struct ip_conntrack_ecache *ec);
+#endif
+
extern struct list_head *ip_conntrack_hash;
extern struct list_head ip_conntrack_expect_list;
extern rwlock_t ip_conntrack_lock;
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -40,6 +40,16 @@ config IP_NF_CONNTRACK_MARK
of packets, but this mark value is kept in the conntrack session
instead of the individual packets.
+config IP_NF_CONNTRACK_EVENTS
+ bool "Connection tracking events"
+ depends on IP_NF_CONNTRACK
+ help
+ If this option is enabled, the connection tracking code will
+ provide a notifier chain that can be used by other kernel code
+ to get notified about changes in the connection tracking state.
+
+ IF unsure, say `N'.
+
config IP_NF_CT_PROTO_SCTP
tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)'
depends on IP_NF_CONNTRACK && EXPERIMENTAL
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -37,6 +37,7 @@
#include <linux/err.h>
#include <linux/percpu.h>
#include <linux/moduleparam.h>
+#include <linux/notifier.h>
/* ip_conntrack_lock protects the main hash table, protocol/helper/expected
registrations, conntrack timers*/
@@ -49,7 +50,7 @@
#include <linux/netfilter_ipv4/ip_conntrack_core.h>
#include <linux/netfilter_ipv4/listhelp.h>
-#define IP_CONNTRACK_VERSION "2.1"
+#define IP_CONNTRACK_VERSION "2.2"
#if 0
#define DEBUGP printk
@@ -76,6 +77,81 @@ unsigned int ip_ct_log_invalid;
static LIST_HEAD(unconfirmed);
static int ip_conntrack_vmalloc;
+#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
+struct notifier_block *ip_conntrack_chain;
+struct notifier_block *ip_conntrack_expect_chain;
+
+DEFINE_PER_CPU(struct ip_conntrack_ecache, ip_conntrack_ecache);
+
+static inline void __deliver_cached_events(struct ip_conntrack_ecache *ecache)
+{
+ if (is_confirmed(ecache->ct) && !is_dying(ecache->ct) && ecache->events)
+ notifier_call_chain(&ip_conntrack_chain, ecache->events,
+ ecache->ct);
+ ecache->events = 0;
+}
+
+void __ip_ct_deliver_cached_events(struct ip_conntrack_ecache *ecache)
+{
+ __deliver_cached_events(ecache);
+}
+
+/* Deliver all cached events for a particular conntrack. This is called
+ * by code prior to async packet handling or freeing the skb */
+void
+ip_conntrack_deliver_cached_events_for(const struct ip_conntrack *ct)
+{
+ struct ip_conntrack_ecache *ecache =
+ &__get_cpu_var(ip_conntrack_ecache);
+
+ if (!ct)
+ return;
+
+ if (ecache->ct == ct) {
+ DEBUGP("ecache: delivering event for %p\n", ct);
+ __deliver_cached_events(ecache);
+ } else {
+ if (net_ratelimit())
+ printk(KERN_WARNING "ecache: want to deliver for %p, "
+ "but cache has %p\n", ct, ecache->ct);
+ }
+
+ /* signalize that events have already been delivered */
+ ecache->ct = NULL;
+}
+
+/* Deliver cached events for old pending events, if current conntrack != old */
+void ip_conntrack_event_cache_init(const struct sk_buff *skb)
+{
+ struct ip_conntrack *ct = (struct ip_conntrack *) skb->nfct;
+ struct ip_conntrack_ecache *ecache =
+ &__get_cpu_var(ip_conntrack_ecache);
+
+ /* take care of delivering potentially old events */
+ if (ecache->ct != ct) {
+ enum ip_conntrack_info ctinfo;
+ /* we have to check, since at startup the cache is NULL */
+ if (likely(ecache->ct)) {
+ DEBUGP("ecache: entered for different conntrack: "
+ "ecache->ct=%p, skb->nfct=%p. delivering "
+ "events\n", ecache->ct, ct);
+ __deliver_cached_events(ecache);
+ ip_conntrack_put(ecache->ct);
+ } else {
+ DEBUGP("ecache: entered for conntrack %p, "
+ "cache was clean before\n", ct);
+ }
+
+ /* initialize for this conntrack/packet */
+ ecache->ct = ip_conntrack_get(skb, &ctinfo);
+ /* ecache->events cleared by __deliver_cached_devents() */
+ } else {
+ DEBUGP("ecache: re-entered for conntrack %p.\n", ct);
+ }
+}
+
+#endif /* CONFIG_IP_NF_CONNTRACK_EVENTS */
+
DEFINE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
void
@@ -230,6 +306,8 @@ destroy_conntrack(struct nf_conntrack *n
IP_NF_ASSERT(atomic_read(&nfct->use) == 0);
IP_NF_ASSERT(!timer_pending(&ct->timeout));
+ set_bit(IPS_DYING_BIT, &ct->status);
+
/* To make sure we don't get any weird locking issues here:
* destroy_conntrack() MUST NOT be called with a write lock
* to ip_conntrack_lock!!! -HW */
@@ -268,6 +346,7 @@ static void death_by_timeout(unsigned lo
{
struct ip_conntrack *ct = (void *)ul_conntrack;
+ ip_conntrack_event(IPCT_DESTROY, ct);
write_lock_bh(&ip_conntrack_lock);
/* Inside lock so preempt is disabled on module removal path.
* Otherwise we can get spurious warnings. */
@@ -381,6 +460,16 @@ __ip_conntrack_confirm(struct sk_buff **
set_bit(IPS_CONFIRMED_BIT, &ct->status);
CONNTRACK_STAT_INC(insert);
write_unlock_bh(&ip_conntrack_lock);
+ if (ct->helper)
+ ip_conntrack_event_cache(IPCT_HELPER, *pskb);
+#ifdef CONFIG_IP_NF_NAT_NEEDED
+ if (test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status) ||
+ test_bit(IPS_DST_NAT_DONE_BIT, &ct->status))
+ ip_conntrack_event_cache(IPCT_NATINFO, *pskb);
+#endif
+ ip_conntrack_event_cache(master_ct(ct) ?
+ IPCT_RELATED : IPCT_NEW, *pskb);
+
return NF_ACCEPT;
}
@@ -609,7 +698,7 @@ unsigned int ip_conntrack_in(unsigned in
struct ip_conntrack *ct;
enum ip_conntrack_info ctinfo;
struct ip_conntrack_protocol *proto;
- int set_reply;
+ int set_reply = 0;
int ret;
/* Previously seen (loopback or untracked)? Ignore. */
@@ -668,6 +757,8 @@ unsigned int ip_conntrack_in(unsigned in
IP_NF_ASSERT((*pskb)->nfct);
+ ip_conntrack_event_cache_init(*pskb);
+
ret = proto->packet(ct, *pskb, ctinfo);
if (ret < 0) {
/* Invalid: inverse of the return code tells
@@ -678,8 +769,8 @@ unsigned int ip_conntrack_in(unsigned in
return -ret;
}
- if (set_reply)
- set_bit(IPS_SEEN_REPLY_BIT, &ct->status);
+ if (set_reply && !test_and_set_bit(IPS_SEEN_REPLY_BIT, &ct->status))
+ ip_conntrack_event_cache(IPCT_STATUS, *pskb);
return ret;
}
@@ -823,6 +914,7 @@ int ip_conntrack_expect_related(struct i
evict_oldest_expect(expect->master);
ip_conntrack_expect_insert(expect);
+ ip_conntrack_expect_event(IPEXP_NEW, expect);
ret = 0;
out:
write_unlock_bh(&ip_conntrack_lock);
@@ -860,8 +952,10 @@ int ip_conntrack_helper_register(struct
static inline int unhelp(struct ip_conntrack_tuple_hash *i,
const struct ip_conntrack_helper *me)
{
- if (tuplehash_to_ctrack(i)->helper == me)
+ if (tuplehash_to_ctrack(i)->helper == me) {
+ ip_conntrack_event(IPCT_HELPER, tuplehash_to_ctrack(i));
tuplehash_to_ctrack(i)->helper = NULL;
+ }
return 0;
}
@@ -923,6 +1017,7 @@ void ip_ct_refresh_acct(struct ip_conntr
if (del_timer(&ct->timeout)) {
ct->timeout.expires = jiffies + extra_jiffies;
add_timer(&ct->timeout);
+ ip_conntrack_event_cache(IPCT_REFRESH, skb);
}
ct_add_counters(ct, ctinfo, skb);
write_unlock_bh(&ip_conntrack_lock);
@@ -1011,6 +1106,23 @@ ip_ct_iterate_cleanup(int (*iter)(struct
ip_conntrack_put(ct);
}
+
+#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
+ {
+ /* we need to deliver all cached events in order to drop
+ * the reference counts */
+ int cpu;
+ for_each_cpu(cpu) {
+ struct ip_conntrack_ecache *ecache =
+ &per_cpu(ip_conntrack_ecache, cpu);
+ if (ecache->ct) {
+ __ip_ct_deliver_cached_events(ecache);
+ ip_conntrack_put(ecache->ct);
+ ecache->ct = NULL;
+ }
+ }
+ }
+#endif
}
/* Fast function for those who don't want to parse /proc (and I don't
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -262,7 +262,8 @@ static int find_nl_seq(u32 seq, const st
}
/* We don't update if it's older than what we have. */
-static void update_nl_seq(u32 nl_seq, struct ip_ct_ftp_master *info, int dir)
+static void update_nl_seq(u32 nl_seq, struct ip_ct_ftp_master *info, int dir,
+ struct sk_buff *skb)
{
unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
@@ -276,10 +277,13 @@ static void update_nl_seq(u32 nl_seq, st
oldest = i;
}
- if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER)
+ if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER) {
info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq;
- else if (oldest != NUM_SEQ_TO_REMEMBER)
+ ip_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, skb);
+ } else if (oldest != NUM_SEQ_TO_REMEMBER) {
info->seq_aft_nl[dir][oldest] = nl_seq;
+ ip_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, skb);
+ }
}
static int help(struct sk_buff **pskb,
@@ -439,7 +443,7 @@ out_update_nl:
/* Now if this ends in \n, update ftp info. Seq may have been
* adjusted by NAT code. */
if (ends_in_nl)
- update_nl_seq(seq, ct_ftp_info,dir);
+ update_nl_seq(seq, ct_ftp_info,dir, *pskb);
out:
spin_unlock_bh(&ip_ftp_lock);
return ret;
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -102,6 +102,7 @@ static int icmp_packet(struct ip_conntra
ct->timeout.function((unsigned long)ct);
} else {
atomic_inc(&ct->proto.icmp.count);
+ ip_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb);
ip_ct_refresh_acct(ct, ctinfo, skb, ip_ct_icmp_timeout);
}
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
--- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
@@ -404,6 +404,8 @@ static int sctp_packet(struct ip_conntra
}
conntrack->proto.sctp.state = newconntrack;
+ if (oldsctpstate != newconntrack)
+ ip_conntrack_event_cache(IPCT_PROTOINFO, skb);
write_unlock_bh(&sctp_lock);
}
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -973,6 +973,10 @@ static int tcp_packet(struct ip_conntrac
? ip_ct_tcp_timeout_max_retrans : *tcp_timeouts[new_state];
write_unlock_bh(&tcp_lock);
+ ip_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb);
+ if (new_state != old_state)
+ ip_conntrack_event_cache(IPCT_PROTOINFO, skb);
+
if (!test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) {
/* If only reply is a RST, we can consider ourselves not to
have an established connection: this is a fairly common
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_udp.c b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
--- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
@@ -73,7 +73,8 @@ static int udp_packet(struct ip_conntrac
ip_ct_refresh_acct(conntrack, ctinfo, skb,
ip_ct_udp_timeout_stream);
/* Also, more likely to be important, and not a probe */
- set_bit(IPS_ASSURED_BIT, &conntrack->status);
+ if (!test_and_set_bit(IPS_ASSURED_BIT, &conntrack->status))
+ ip_conntrack_event_cache(IPCT_STATUS, skb);
} else
ip_ct_refresh_acct(conntrack, ctinfo, skb, ip_ct_udp_timeout);
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -402,6 +402,7 @@ static unsigned int ip_confirm(unsigned
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
+ ip_conntrack_event_cache_init(*pskb);
/* We've seen it coming out the other side: confirm it */
return ip_conntrack_confirm(pskb);
}
@@ -419,6 +420,7 @@ static unsigned int ip_conntrack_help(un
ct = ip_conntrack_get(*pskb, &ctinfo);
if (ct && ct->helper) {
unsigned int ret;
+ ip_conntrack_event_cache_init(*pskb);
ret = ct->helper->help(pskb, ct, ctinfo);
if (ret != NF_ACCEPT)
return ret;
@@ -889,6 +891,7 @@ static int init_or_cleanup(int init)
return ret;
cleanup:
+ synchronize_net();
#ifdef CONFIG_SYSCTL
unregister_sysctl_table(ip_ct_sysctl_header);
cleanup_localinops:
@@ -971,6 +974,13 @@ void need_ip_conntrack(void)
{
}
+#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
+EXPORT_SYMBOL_GPL(ip_conntrack_chain);
+EXPORT_SYMBOL_GPL(ip_conntrack_expect_chain);
+EXPORT_SYMBOL_GPL(ip_conntrack_register_notifier);
+EXPORT_SYMBOL_GPL(ip_conntrack_unregister_notifier);
+EXPORT_PER_CPU_SYMBOL_GPL(ip_conntrack_ecache);
+#endif
EXPORT_SYMBOL(ip_conntrack_protocol_register);
EXPORT_SYMBOL(ip_conntrack_protocol_unregister);
EXPORT_SYMBOL(ip_ct_get_tuple);
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: [PATCH] reduce netfilte sk_buff enlargement
From: Harald Welte @ 2005-07-20 13:23 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Marcel Holtmann, netfilter-devel, wensong
In-Reply-To: <20050718.203145.105430424.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]
On Mon, Jul 18, 2005 at 08:31:45PM -0700, David S. Miller wrote:
> From: Harald Welte <laforge@netfilter.org>
> Date: Mon, 18 Jul 2005 00:04:51 +0200
>
> > The only real in-tree user of nfcache was IPVS, who only needs a single
> > bit. Unfortunately I couldn't find some other free bit in sk_buff to
> > stuff that bit into, so I introduced a separate field for them. Maybe
> > the IPVS guys can resolve that to further save space.
>
> I think we must resolve this one before 2.6.14 goes out, which
> gives us a lot of time, but for now I'll eat that one-bit member.
Well, I hope IPVS people will take care of this. I don't really know
that code too well...
> > Initially I wanted to shrink pkt_type to three bits (PACKET_HOST and
> > alike are only 6 values defined), but unfortunately the bluetooth code
> > overloads pkt_type :(
>
> This also must be cured somehow, that really isn't a clean nor nice
> usage of this field.
I just ran into Marcel Holtmann earlier today. He thinks moving that
data into the cb is fine, though he has to double-check that.
He also said that he really only needs 5 bits, so even if the current
pkt_type overloading would persist, we could probably shrink it to make
space for the IPVS bit.
--
- Harald Welte <laforge@netfilter.org> http://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
* Re: [2.6 patch] VIA_VELOCITY must depend on INET
From: Alan Cox @ 2005-07-20 11:26 UTC (permalink / raw)
To: Adrian Bunk; +Cc: jgarzik, netdev, linux-kernel
In-Reply-To: <20050719135523.GF5031@stusta.de>
On Maw, 2005-07-19 at 15:55 +0200, Adrian Bunk wrote:
> VIA_VELOCITY=y and INET=n results in the following compile error:
>
> <-- snip -->
>
> ...
> LD .tmp_vmlinux1
> drivers/built-in.o: In function `velocity_register_notifier':
> via-velocity.c:(.text+0x3462c6): undefined reference to `register_inetaddr_notifier'
> drivers/built-in.o: In function `velocity_unregister_notifier':
> via-velocity.c:(.text+0x3462d6): undefined reference to `unregister_inetaddr_notifier'
> make: *** [.tmp_vmlinux1] Error 1
Alternatively you could drop those functions when CONFIG_INET is n as
they are only used for wake on arp
^ permalink raw reply
* Re: [PATCH 1/8][ATM]: [zatm] eliminate kfree warning (from Tobias Hirning <sskyman@web.de>)
From: Jakub Jelinek @ 2005-07-20 7:19 UTC (permalink / raw)
To: chas williams - CONTRACTOR; +Cc: netdev, davem
In-Reply-To: <200507192044.j6JKirFb027183@ginger.cmf.nrl.navy.mil>
On Tue, Jul 19, 2005 at 04:44:54PM -0400, chas williams - CONTRACTOR wrote:
> please apply to 2.6 -- thanks!
>
> [ATM]: [zatm] eliminate kfree warning (from Tobias Hirning <sskyman@web.de>)
>
> Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil>
>
>
> ---
> commit 4932248439d20412610ffaade625cbde0e001e37
> tree 35a60e3551f5f1abced8a435238575c488041af6
> parent 238921d2cb04eb6dcc2ff5914d555d7dcaa4dfc5
> author chas williams <chas@relax.(none)> Wed, 06 Jul 2005 13:10:18 -0400
> committer chas williams <chas@relax.(none)> Wed, 06 Jul 2005 13:10:18 -0400
>
> drivers/atm/zatm.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
> --- a/drivers/atm/zatm.c
> +++ b/drivers/atm/zatm.c
> @@ -1339,7 +1339,7 @@ static int __init zatm_start(struct atm_
> return 0;
> out:
> for (i = 0; i < NR_MBX; i++)
> - kfree(zatm_dev->mbx_start[i]);
> + kfree(&zatm_dev->mbx_start[i]);
This can't be right. zatm_dev->mbx_start[i] is allocated with:
1306 here = (unsigned long) kmalloc(2*MBX_SIZE(i),
1307 GFP_KERNEL);
1308 if (!here) {
1309 error = -ENOMEM;
1310 goto out;
1311 }
1312 if ((here^(here+MBX_SIZE(i))) & ~0xffffUL)/* paranoia */
1313 here = (here & ~0xffffUL)+0x10000;
1314 zatm_dev->mbx_start[i] = here;
so even kfree((void *)zatm_dev->mbx_start[i]); is wrong in case
there was an alignment, but kfree(&zatm_dev->mbx_start[i])
is wrong in all cases.
Jakub
^ permalink raw reply
* [patch linux-2.6.13-rc2-gitXX 1/1] zatm: mailbox converted to pci_alloc_consistent()
From: Francois Romieu @ 2005-07-19 22:36 UTC (permalink / raw)
To: chas williams; +Cc: netdev, davem
In-Reply-To: <20050719223134.GA24535@electric-eye.fr.zoreil.com>
mailbox converted to pci_alloc_consistent()
- request_region() is not needed: zatm_init_one() issues
pci_request_regions();
- the warning related to kfree(zatm_dev->mbx_start) disappears;
Compiled with i386 and sparc64 as target.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
diff -puN drivers/atm/zatm.c~drivers-atm-zatm-mbx drivers/atm/zatm.c
--- linux-2.6.13-rc2-gitXX/drivers/atm/zatm.c~drivers-atm-zatm-mbx 2005-07-19 23:40:48.696490366 +0200
+++ linux-2.6.13-rc2-gitXX-fr/drivers/atm/zatm.c 2005-07-20 00:27:48.263131297 +0200
@@ -16,9 +16,9 @@
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/delay.h>
-#include <linux/ioport.h> /* for request_region */
#include <linux/uio.h>
#include <linux/init.h>
+#include <linux/dma-mapping.h>
#include <linux/atm_zatm.h>
#include <linux/capability.h>
#include <linux/bitops.h>
@@ -1260,22 +1260,22 @@ static int __init zatm_init(struct atm_d
static int __init zatm_start(struct atm_dev *dev)
{
- struct zatm_dev *zatm_dev;
+ struct zatm_dev *zatm_dev = ZATM_DEV(dev);
+ struct pci_dev *pdev = zatm_dev->pci_dev;
unsigned long curr;
int pools,vccs,rx;
- int error,i,ld;
+ int error, i, ld;
DPRINTK("zatm_start\n");
- zatm_dev = ZATM_DEV(dev);
zatm_dev->rx_map = zatm_dev->tx_map = NULL;
- for (i = 0; i < NR_MBX; i++)
- zatm_dev->mbx_start[i] = 0;
- if (request_irq(zatm_dev->irq,&zatm_int,SA_SHIRQ,DEV_LABEL,dev)) {
- printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n",
- dev->number,zatm_dev->irq);
- return -EAGAIN;
+ for (i = 0; i < NR_MBX; i++)
+ zatm_dev->mbx_start[i] = 0;
+ error = request_irq(zatm_dev->irq, zatm_int, SA_SHIRQ, DEV_LABEL, dev);
+ if (error < 0) {
+ printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n",
+ dev->number,zatm_dev->irq);
+ goto done;
}
- request_region(zatm_dev->base,uPD98401_PORTS,DEV_LABEL);
/* define memory regions */
pools = NR_POOLS;
if (NR_SHAPERS*SHAPER_SIZE > pools*POOL_SIZE)
@@ -1302,51 +1302,66 @@ static int __init zatm_start(struct atm_
"%ld VCs\n",dev->number,NR_SHAPERS,pools,rx,
(zatm_dev->mem-curr*4)/VC_SIZE);
/* create mailboxes */
- for (i = 0; i < NR_MBX; i++)
- if (mbx_entries[i]) {
- unsigned long here;
-
- here = (unsigned long) kmalloc(2*MBX_SIZE(i),
- GFP_KERNEL);
- if (!here) {
- error = -ENOMEM;
- goto out;
- }
- if ((here^(here+MBX_SIZE(i))) & ~0xffffUL)/* paranoia */
- here = (here & ~0xffffUL)+0x10000;
- zatm_dev->mbx_start[i] = here;
- if ((here^virt_to_bus((void *) here)) & 0xffff) {
- printk(KERN_ERR DEV_LABEL "(itf %d): system "
- "bus incompatible with driver\n",
- dev->number);
- error = -ENODEV;
- goto out;
- }
- DPRINTK("mbx@0x%08lx-0x%08lx\n",here,here+MBX_SIZE(i));
- zatm_dev->mbx_end[i] = (here+MBX_SIZE(i)) & 0xffff;
- zout(virt_to_bus((void *) here) >> 16,MSH(i));
- zout(virt_to_bus((void *) here),MSL(i));
- zout((here+MBX_SIZE(i)) & 0xffff,MBA(i));
- zout(here & 0xffff,MTA(i));
- zout(here & 0xffff,MWA(i));
- }
+ for (i = 0; i < NR_MBX; i++) {
+ void *mbx;
+ dma_addr_t mbx_dma;
+
+ if (!mbx_entries[i])
+ continue;
+ mbx = pci_alloc_consistent(pdev, 2*MBX_SIZE(i), &mbx_dma);
+ if (!mbx) {
+ error = -ENOMEM;
+ goto out;
+ }
+ /*
+ * Alignment provided by pci_alloc_consistent() isn't enough
+ * for this device.
+ */
+ if (((unsigned long)mbx ^ mbx_dma) & 0xffff) {
+ printk(KERN_ERR DEV_LABEL "(itf %d): system "
+ "bus incompatible with driver\n", dev->number);
+ pci_free_consistent(pdev, 2*MBX_SIZE(i), mbx, mbx_dma);
+ error = -ENODEV;
+ goto out;
+ }
+ DPRINTK("mbx@0x%08lx-0x%08lx\n", mbx, mbx + MBX_SIZE(i));
+ zatm_dev->mbx_start[i] = (unsigned long)mbx;
+ zatm_dev->mbx_dma[i] = mbx_dma;
+ zatm_dev->mbx_end[i] = (zatm_dev->mbx_start[i] + MBX_SIZE(i)) &
+ 0xffff;
+ zout(mbx_dma >> 16, MSH(i));
+ zout(mbx_dma, MSL(i));
+ zout(zatm_dev->mbx_end[i], MBA(i));
+ zout((unsigned long)mbx & 0xffff, MTA(i));
+ zout((unsigned long)mbx & 0xffff, MWA(i));
+ }
error = start_tx(dev);
- if (error) goto out;
+ if (error)
+ goto out;
error = start_rx(dev);
- if (error) goto out;
+ if (error)
+ goto out_tx;
error = dev->phy->start(dev);
- if (error) goto out;
+ if (error)
+ goto out_rx;
zout(0xffffffff,IMR); /* enable interrupts */
/* enable TX & RX */
zout(zin(GMR) | uPD98401_GMR_SE | uPD98401_GMR_RE,GMR);
- return 0;
- out:
- for (i = 0; i < NR_MBX; i++)
- kfree(zatm_dev->mbx_start[i]);
+done:
+ return error;
+
+out_rx:
kfree(zatm_dev->rx_map);
+out_tx:
kfree(zatm_dev->tx_map);
+out:
+ while (i-- > 0) {
+ pci_free_consistent(pdev, 2*MBX_SIZE(i),
+ (void *)zatm_dev->mbx_start[i],
+ zatm_dev->mbx_dma[i]);
+ }
free_irq(zatm_dev->irq, dev);
- return error;
+ goto done;
}
diff -puN drivers/atm/zatm.h~drivers-atm-zatm-mbx drivers/atm/zatm.h
--- linux-2.6.13-rc2-gitXX/drivers/atm/zatm.h~drivers-atm-zatm-mbx 2005-07-19 23:40:48.711487946 +0200
+++ linux-2.6.13-rc2-gitXX-fr/drivers/atm/zatm.h 2005-07-19 23:40:48.764479397 +0200
@@ -73,6 +73,7 @@ struct zatm_dev {
int chans; /* map size, must be 2^n */
/*-------------------------------- mailboxes */
unsigned long mbx_start[NR_MBX];/* start addresses */
+ dma_addr_t mbx_dma[NR_MBX];
u16 mbx_end[NR_MBX]; /* end offset (in bytes) */
/*-------------------------------- other pointers */
u32 pool_base; /* Free buffer pool dsc (word addr) */
_
^ permalink raw reply
* Re: [PATCH 1/8][ATM]: [zatm] eliminate kfree warning (from Tobias Hirning <sskyman@web.de>)
From: Francois Romieu @ 2005-07-19 22:31 UTC (permalink / raw)
To: chas williams - CONTRACTOR; +Cc: netdev, davem
In-Reply-To: <200507192044.j6JKirFb027183@ginger.cmf.nrl.navy.mil>
chas williams - CONTRACTOR <chas@cmf.nrl.navy.mil> :
[...]
> diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
> --- a/drivers/atm/zatm.c
> +++ b/drivers/atm/zatm.c
> @@ -1339,7 +1339,7 @@ static int __init zatm_start(struct atm_
> return 0;
> out:
> for (i = 0; i < NR_MBX; i++)
> - kfree(zatm_dev->mbx_start[i]);
> + kfree(&zatm_dev->mbx_start[i]);
> kfree(zatm_dev->rx_map);
> kfree(zatm_dev->tx_map);
> free_irq(zatm_dev->irq, dev);
Wow...
static int __init zatm_start(struct atm_dev *dev)
{
[...]
for (i = 0; i < NR_MBX; i++)
[blah blah]
here = (unsigned long) kmalloc(2*MBX_SIZE(i),
GFP_KERNEL);
[blah blah]
zatm_dev->mbx_start[i] = here;
There is some stuff in my patchbucket for this one, please wait a minute.
--
Ueimor
^ permalink raw reply
* Re: [PATCH 2.6.12-rc4] IPv4/IPv6: USO v2, Scatter-gather approach
From: David S. Miller @ 2005-07-19 21:23 UTC (permalink / raw)
To: ravinandan.arakali
Cc: jgarzik, netdev, raghavendra.koushik, leonid.grossman,
ananda.raju, rapuru.sriram
In-Reply-To: <20050603004106.BAB6A7B990@linux.site>
From: ravinandan.arakali@neterion.com
Date: Thu, 2 Jun 2005 17:41:06 -0700 (PDT)
> Attached below is version 2 of kernel patch for UDP Large send offload
> feature. This patch uses the "Scatter-Gather" approach.
> It also incorporates David Miller's comments on the first version.
I've reviewed this patches, and I think there is a problem
with the sock_append_data() scheme. You disallow the case
where there is an SKB on the write queue already.
This breaks NFS, and other things using MSG_MORE and UDP_CORK.
They do a two step packet building:
1) Send protocol headers, f.e. NFS
2) Send file contents via sendfile()
3) Uncork socket so packet gets emitted
and due to this check:
+ if (skb_queue_len(&sk->sk_write_queue)) {
+ *err = -EOPNOTSUPP;
+ return NULL;
+ }
you end up not supporting this correctly.
So we have two options, either add support for corked socket
handling to sock_append_data() or we go with the frag_list
patch which doesn't have this problem.
I prefer the frag_list patch from a cleanliness perspective,
however I remember you saying that the sock_append_data()
approach obtained better performance. And that seems clear
since there will be less TX descriptors needed to send such
frames unless the driver does coalescing as it walks the
frag_list chain.
^ permalink raw reply
* Re: [2.6 patch] NETCONSOLE must depend on INET
From: David S. Miller @ 2005-07-19 21:01 UTC (permalink / raw)
To: bunk; +Cc: jgarzik, netdev, linux-kernel
In-Reply-To: <20050719182919.GA5531@stusta.de>
From: Adrian Bunk <bunk@stusta.de>
Date: Tue, 19 Jul 2005 20:29:19 +0200
> NETCONSOLE=y and INET=n results in the following compile error:
Also applied, thanks Adrian.
^ permalink raw reply
* Re: [2.6 patch] BRIDGE_EBT_ARPREPLY must depend on INET
From: David S. Miller @ 2005-07-19 21:00 UTC (permalink / raw)
To: bunk; +Cc: netdev, netfilter-devel, linux-kernel, coreteam, bridge,
shemminger
In-Reply-To: <20050719135529.GH5031@stusta.de>
From: Adrian Bunk <bunk@stusta.de>
Date: Tue, 19 Jul 2005 15:55:29 +0200
> BRIDGE_EBT_ARPREPLY=y and INET=n results in the following compile error:
Applied, thanks Adrian.
^ permalink raw reply
* [PATCH 8/8][ATM]: [speedtch] cure atm_printk() macro gcc-2.95 compile error
From: chas williams - CONTRACTOR @ 2005-07-19 20:47 UTC (permalink / raw)
To: netdev; +Cc: davem
please apply to 2.6 -- thanks!
[ATM]: [speedtch] cure atm_printk() macro gcc-2.95 compile error
Signed-off-by: Duncan Sands <baldrick@free.fr>
Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil>
---
commit 73500df545c8763d662192d9749fd8d64209c819
tree 0f73d33200e626e8ef0af506dbed40a3850c609b
parent 4932248439d20412610ffaade625cbde0e001e37
author chas williams <chas@relax.(none)> Wed, 06 Jul 2005 13:22:52 -0400
committer chas williams <chas@relax.(none)> Wed, 06 Jul 2005 13:22:52 -0400
drivers/usb/atm/speedtch.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -448,19 +448,19 @@ static void speedtch_check_status(struct
case 0:
atm_dev->signal = ATM_PHY_SIG_LOST;
if (instance->last_status)
- atm_info(usbatm, "ADSL line is down\n");
+ atm_info(usbatm, "%s\n", "ADSL line is down");
/* It may never resync again unless we ask it to... */
ret = speedtch_start_synchro(instance);
break;
case 0x08:
atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
- atm_info(usbatm, "ADSL line is blocked?\n");
+ atm_info(usbatm, "%s\n", "ADSL line is blocked?");
break;
case 0x10:
atm_dev->signal = ATM_PHY_SIG_LOST;
- atm_info(usbatm, "ADSL line is synchronising\n");
+ atm_info(usbatm, "%s\n", "ADSL line is synchronising");
break;
case 0x20:
@@ -502,7 +502,7 @@ static void speedtch_status_poll(unsigne
if (instance->poll_delay < MAX_POLL_DELAY)
mod_timer(&instance->status_checker.timer, jiffies + msecs_to_jiffies(instance->poll_delay));
else
- atm_warn(instance->usbatm, "Too many failures - disabling line status polling\n");
+ atm_warn(instance->usbatm, "%s\n", "Too many failures - disabling line status polling");
}
static void speedtch_resubmit_int(unsigned long data)
@@ -545,9 +545,9 @@ static void speedtch_handle_int(struct u
if ((count == 6) && !memcmp(up_int, instance->int_data, 6)) {
del_timer(&instance->status_checker.timer);
- atm_info(usbatm, "DSL line goes up\n");
+ atm_info(usbatm, "%s\n", "DSL line goes up");
} else if ((count == 6) && !memcmp(down_int, instance->int_data, 6)) {
- atm_info(usbatm, "DSL line goes down\n");
+ atm_info(usbatm, "%s\n", "DSL line goes down");
} else {
int i;
^ permalink raw reply
* [PATCH 7/8][ATM]: Trivial spelling fix patch for net/Kconfig
From: chas williams - CONTRACTOR @ 2005-07-19 20:46 UTC (permalink / raw)
To: netdev; +Cc: davem
please apply to 2.6 -- thanks!
[ATM]: Trivial spelling fix patch for net/Kconfig
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil>
---
commit eefc05048924978c1e28835bf5085c5de2e653d2
tree b453e78b3eca05558e5c3ff8d9cf9ab9f2ee9bd9
parent ac4755cc8eefb198945e76d4069184454c0819ce
author chas williams <chas@relax.(none)> Tue, 19 Jul 2005 14:58:08 -0400
committer chas williams <chas@relax.(none)> Tue, 19 Jul 2005 14:58:08 -0400
net/atm/Kconfig | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/atm/Kconfig b/net/atm/Kconfig
--- a/net/atm/Kconfig
+++ b/net/atm/Kconfig
@@ -60,7 +60,7 @@ config ATM_BR2684
tristate "RFC1483/2684 Bridged protocols"
depends on ATM && INET
help
- ATM PVCs can carry ethernet PDUs according to rfc2684 (formerly 1483)
+ ATM PVCs can carry ethernet PDUs according to RFC2684 (formerly 1483)
This device will act like an ethernet from the kernels point of view,
with the traffic being carried by ATM PVCs (currently 1 PVC/device).
This is sometimes used over DSL lines. If in doubt, say N.
@@ -69,6 +69,6 @@ config ATM_BR2684_IPFILTER
bool "Per-VC IP filter kludge"
depends on ATM_BR2684
help
- This is an experimental mechanism for users who need to terminating a
+ This is an experimental mechanism for users who need to terminate a
large number of IP-only vcc's. Do not enable this unless you are sure
you know what you are doing.
^ permalink raw reply
* [PATCH 6/8][ATM]: [ambassador] Fix the sparse warning "implicit cast to nocast type"
From: chas williams - CONTRACTOR @ 2005-07-19 20:45 UTC (permalink / raw)
To: netdev; +Cc: davem
please apply to 2.6 -- thanks!
[ATM]: [ambassador] Fix the sparse warning "implicit cast to nocast type"
Signed-off-by: Victor Fusco <victor@cetuc.puc-rio.br>
Signed-off-by: Domen Puncer <domen@coderock.org>
Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil>
---
commit 8e1e58dcc5ec7ea3c29c3ae38156afc2af150cea
tree e12e7c184de1170f179a17b4a3adf45986ef5a9e
parent 6e59c9c1673a7b31f00cc8dd79f1e11abf91be9a
author chas williams <chas@relax.(none)> Tue, 19 Jul 2005 15:08:43 -0400
committer chas williams <chas@relax.(none)> Tue, 19 Jul 2005 15:08:43 -0400
drivers/atm/ambassador.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -794,7 +794,9 @@ static void drain_rx_pools (amb_dev * de
drain_rx_pool (dev, pool);
}
-static inline void fill_rx_pool (amb_dev * dev, unsigned char pool, int priority) {
+static inline void fill_rx_pool (amb_dev * dev, unsigned char pool,
+ unsigned int __nocast priority)
+{
rx_in rx;
amb_rxq * rxq;
^ permalink raw reply
* [PATCH 5/8][ATM]: [firestream] fix the sparse warning "implicit cast to nocast type"
From: chas williams - CONTRACTOR @ 2005-07-19 20:45 UTC (permalink / raw)
To: netdev; +Cc: davem
please apply to 2.6 -- thanks!
[ATM]: [firestream] fix the sparse warning "implicit cast to nocast type"
Signed-off-by: Victor Fusco <victor@cetuc.puc-rio.br>
Signed-off-by: Domen Puncer <domen@coderock.org>
Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil>
---
commit 6e59c9c1673a7b31f00cc8dd79f1e11abf91be9a
tree 962d15261cc88a8b094461689bcc122896508333
parent 9c893a8cd5716416ee719a57e04e01aeb2c68bd3
author chas williams <chas@relax.(none)> Tue, 19 Jul 2005 15:07:01 -0400
committer chas williams <chas@relax.(none)> Tue, 19 Jul 2005 15:07:01 -0400
drivers/atm/firestream.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -1374,7 +1374,8 @@ static void reset_chip (struct fs_dev *d
}
}
-static void __devinit *aligned_kmalloc (int size, int flags, int alignment)
+static void __devinit *aligned_kmalloc (int size, unsigned int __nocast flags,
+ int alignment)
{
void *t;
@@ -1464,7 +1465,8 @@ static inline int nr_buffers_in_freepool
does. I've seen "receive abort: no buffers" and things started
working again after that... -- REW */
-static void top_off_fp (struct fs_dev *dev, struct freepool *fp, int gfp_flags)
+static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
+ unsigned int __nocast gfp_flags)
{
struct FS_BPENTRY *qe, *ne;
struct sk_buff *skb;
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox