* [PATCH -next] netxen: fix build when CONFIG_INET=n
From: Randy Dunlap @ 2009-07-28 18:21 UTC (permalink / raw)
To: Stephen Rothwell, davem; +Cc: linux-next, LKML, netdev, Dhananjay Phadke
In-Reply-To: <20090728174224.647cc3ba.sfr@canb.auug.org.au>
From: Randy Dunlap <randy.dunlap@oracle.com>
Fix netxen build errors when CONFIG_INET=n:
netxen_nic_main.c:(.text+0x1abb8a): undefined reference to `in_dev_finish_destroy'
netxen_nic_main.c:(.init.text+0xd86e): undefined reference to `register_inetaddr_notifier'
netxen_nic_main.c:(.exit.text+0x1b70): undefined reference to `unregister_inetaddr_notifier'
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Dhananjay Phadke <dhananjay@netxen.com>
---
drivers/net/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- linux-next-20090728.orig/drivers/net/Kconfig
+++ linux-next-20090728/drivers/net/Kconfig
@@ -2666,7 +2666,7 @@ config MYRI10GE_DCA
config NETXEN_NIC
tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC"
- depends on PCI
+ depends on PCI && INET
help
This enables the support for NetXen's Gigabit Ethernet card.
---
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Add networking wireless drivers section
From: Randy Dunlap @ 2009-07-28 18:15 UTC (permalink / raw)
To: Joe Perches
Cc: David Miller, John W. Linville, julia-dAYI7NvHqcQ,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1248804397.18284.5.camel-AkRN8/LKpobuYGix6ZUp1Q@public.gmane.org>
On Tue, 28 Jul 2009 11:06:37 -0700 Joe Perches wrote:
> On Tue, 2009-07-28 at 10:30 -0700, David Miller wrote:
> > Wireless patches need to be CC:'d to linux-wireless so that
> > John Linville can notice and pick them up
>
> Signed-off-by: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ebc2691..0574aad 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -4186,6 +4186,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
> S: Odd Fixes
> F: drivers/net/
>
> +NETWORKING WIRELESS DRIVERS
> +L: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> +T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git
> +S: Odd Fixes
> +F: drivers/net/wireless/
> +
Already have this:
NETWORKING [WIRELESS]
P: John W. Linville
M: linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org
L: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git
S: Maintained
F: net/wireless/
F: include/net/ieee80211*
F: include/linux/wireless.h
---
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] MAINTAINERS: Add networking wireless drivers section
From: Joe Perches @ 2009-07-28 18:06 UTC (permalink / raw)
To: David Miller, John W. Linville
Cc: julia, netdev, linux-kernel, kernel-janitors, linux-wireless
In-Reply-To: <20090728.103044.179053537.davem@davemloft.net>
On Tue, 2009-07-28 at 10:30 -0700, David Miller wrote:
> Wireless patches need to be CC:'d to linux-wireless so that
> John Linville can notice and pick them up
Signed-off-by: Joe Perches <joe@perches.com>
diff --git a/MAINTAINERS b/MAINTAINERS
index ebc2691..0574aad 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4186,6 +4186,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
S: Odd Fixes
F: drivers/net/
+NETWORKING WIRELESS DRIVERS
+L: linux-wireless@vger.kernel.org
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git
+S: Odd Fixes
+F: drivers/net/wireless/
+
NETXEN (1/10) GbE SUPPORT
P: Dhananjay Phadke
M: dhananjay@netxen.com
^ permalink raw reply related
* Re: [PATCH 5/9] drivers/net/wireless: correct error-handling code
From: John W. Linville @ 2009-07-28 17:52 UTC (permalink / raw)
To: David Miller; +Cc: julia, netdev, linux-kernel, kernel-janitors, linux-wireless
In-Reply-To: <20090728.103044.179053537.davem@davemloft.net>
On Tue, Jul 28, 2009 at 10:30:44AM -0700, David Miller wrote:
> From: Julia Lawall <julia@diku.dk>
> Date: Tue, 28 Jul 2009 17:54:24 +0200 (CEST)
>
> Wireless patches need to be CC:'d to linux-wireless so that
> John Linville can notice and pick them up. Added...
Thanks...FWIW, I've got a nearly identical patch from Dan Carpenter
queued already.
John
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
¡Viva Honduras Libre!
^ permalink raw reply
* [PATCH] pppoe: fix race at init time
From: Eric Dumazet @ 2009-07-28 17:46 UTC (permalink / raw)
To: David S. Miller
Cc: Pavel Emelyanov, Igor M Podlesny, Andrew Morton, netdev,
Cyrill Gorcunov
In-Reply-To: <4A6F017B.4060909@gmail.com>
Eric Dumazet a écrit :
> Eric Dumazet a écrit :
>> Seems drivers/net/pppol2tp.c is a suspect...
>>
>> It uses register_pernet_gen_device() from pppol2tp_init()
>> but doesnt call unregister_pernet_gen_device()
>
> OK patch seems really easy...
>
> This bug was added in commit 4e9fb8016a351b5b9da7fea32bcfdbc9d836e421
> net: pppol2tp - introduce net-namespace functionality
>
> So this is a stable candidate I guess ?
>
> Thank you
So Igor still has a panic... lets try a third patch then :)
[PATCH] pppoe: fix race at init time
I believe we have a race in ppoe_init() :
As soon as dev_add_pack(&pppoes_ptype); and/or dev_add_pack(&pppoed_ptype);
are called, we can receive packets while nets not yet fully ready
(ie : pppoe_init_net() not yet called)
This means we should be prepared to get a NULL pointer
from net_generic(net, pppoe_net_id) call.
We miss this NULL check in get_item() and possibly crash if this nets
has no struct pppoe_net attached yet. Other subroutines
are safe.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index f0031f1..e50af8c 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -237,14 +237,15 @@ static struct pppox_sock *__delete_item(struct pppoe_net *pn, __be16 sid,
static inline struct pppox_sock *get_item(struct pppoe_net *pn, __be16 sid,
unsigned char *addr, int ifindex)
{
- struct pppox_sock *po;
-
- read_lock_bh(&pn->hash_lock);
- po = __get_item(pn, sid, addr, ifindex);
- if (po)
- sock_hold(sk_pppox(po));
- read_unlock_bh(&pn->hash_lock);
-
+ struct pppox_sock *po = NULL;
+
+ if (pn) {
+ read_lock_bh(&pn->hash_lock);
+ po = __get_item(pn, sid, addr, ifindex);
+ if (po)
+ sock_hold(sk_pppox(po));
+ read_unlock_bh(&pn->hash_lock);
+ }
return po;
}
^ permalink raw reply related
* Re: [PATCH] ppp: fix lost fragments in ppp_mp_explode() (resubmit)
From: Ben McKeegan @ 2009-07-28 17:43 UTC (permalink / raw)
To: davem, paulus; +Cc: gabriele.paoloni, netdev, linux-ppp
In-Reply-To: <4A6EFEB4.2000500@netservers.co.uk>
(resubmitted as MUA mangled original patch)
This patch fixes the corner cases where the sum of MTU of the free
channels (adjusted for fragmentation overheads) is less than the MTU of
PPP link. There are at least 3 situations where this case might arise:
- some of the channels are busy
- the multilink session is running in a degraded state (i.e. with less
than its full complement of active channels)
- by design, where multilink protocol is being used to artificially
increase the effective link MTU of a single link.
Without this patch, at most 1 fragment is ever sent per free channel for
a given PPP frame and any remaining part of the PPP frame that does not
fit into those fragments is silently discarded.
This patch restores the original behaviour which was broken by commit
9c705260feea6ae329bc6b6d5f6d2ef0227eda0a 'ppp:ppp_mp_explode()
redesign'. Once all 'free' channels have been given a fragment, an
additional fragment is queued to each available channel in turn, as many
times as necessary, until the entire PPP frame has been consumed.
Signed-off-by: Ben McKeegan <ben@netservers.co.uk>
---
diff -uprN linux-2.6.31-rc4/drivers/net/ppp_generic.c linux-2.6.31-rc4-multilink-fix/drivers/net/ppp_generic.c
--- linux-2.6.31-rc4/drivers/net/ppp_generic.c 2009-07-23 03:32:59.000000000 +0100
+++ linux-2.6.31-rc4-multilink-fix/drivers/net/ppp_generic.c 2009-07-28 13:54:49.000000000 +0100
@@ -1384,7 +1384,7 @@ static int ppp_mp_explode(struct ppp *pp
/* create a fragment for each channel */
bits = B;
- while (nfree > 0 && len > 0) {
+ while (len > 0) {
list = list->next;
if (list == &ppp->channels) {
i = 0;
@@ -1431,29 +1431,31 @@ static int ppp_mp_explode(struct ppp *pp
*otherwise divide it according to the speed
*of the channel we are going to transmit on
*/
- if (pch->speed == 0) {
- flen = totlen/nfree ;
- if (nbigger > 0) {
- flen++;
- nbigger--;
- }
- } else {
- flen = (((totfree - nzero)*(totlen + hdrlen*totfree)) /
- ((totspeed*totfree)/pch->speed)) - hdrlen;
- if (nbigger > 0) {
- flen += ((totfree - nzero)*pch->speed)/totspeed;
- nbigger -= ((totfree - nzero)*pch->speed)/
+ if (nfree > 0) {
+ if (pch->speed == 0) {
+ flen = totlen/nfree ;
+ if (nbigger > 0) {
+ flen++;
+ nbigger--;
+ }
+ } else {
+ flen = (((totfree - nzero)*(totlen + hdrlen*totfree)) /
+ ((totspeed*totfree)/pch->speed)) - hdrlen;
+ if (nbigger > 0) {
+ flen += ((totfree - nzero)*pch->speed)/totspeed;
+ nbigger -= ((totfree - nzero)*pch->speed)/
totspeed;
+ }
}
+ nfree--;
}
- nfree--;
/*
*check if we are on the last channel or
*we exceded the lenght of the data to
*fragment
*/
- if ((nfree == 0) || (flen > len))
+ if ((nfree <= 0) || (flen > len))
flen = len;
/*
*it is not worth to tx on slow channels:
@@ -1467,7 +1469,7 @@ static int ppp_mp_explode(struct ppp *pp
continue;
}
- mtu = pch->chan->mtu + 2 - hdrlen;
+ mtu = pch->chan->mtu - hdrlen;
if (mtu < 4)
mtu = 4;
if (flen > mtu)
^ permalink raw reply
* Re: [PATCH 5/9] drivers/net/wireless: correct error-handling code
From: David Miller @ 2009-07-28 17:30 UTC (permalink / raw)
To: julia-dAYI7NvHqcQ
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <Pine.LNX.4.64.0907281753540.28189-QfmoRoYWmW9knbxzx/v8hQ@public.gmane.org>
From: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
Date: Tue, 28 Jul 2009 17:54:24 +0200 (CEST)
Wireless patches need to be CC:'d to linux-wireless so that
John Linville can notice and pick them up. Added...
> From: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
>
> iwm_wdev_alloc returns an ERR_PTR value in an error case instead of NULL.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @match exists@
> expression x, E;
> statement S1, S2;
> @@
>
> x = iwm_wdev_alloc(...)
> ... when != x = E
> (
> * if (x == NULL || ...) S1 else S2
> |
> * if (x == NULL && ...) S1 else S2
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
>
> ---
> drivers/net/wireless/iwmc3200wifi/netdev.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
> index bb71f8a..e1c6693 100644
> --- a/drivers/net/wireless/iwmc3200wifi/netdev.c
> +++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
> @@ -99,7 +99,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
> int ret = 0;
>
> wdev = iwm_wdev_alloc(sizeof_bus, dev);
> - if (!wdev) {
> + if (IS_ERR(wdev)) {
> dev_err(dev, "no memory for wireless device instance\n");
> return ERR_PTR(-ENOMEM);
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] net: shrink net_device by #ifdef-ing protocol-specific members
From: David Miller @ 2009-07-28 17:28 UTC (permalink / raw)
To: opurdila; +Cc: lgrijincu, netdev, eric.dumazet
In-Reply-To: <200907281743.27871.opurdila@ixiacom.com>
From: Octavian Purdila <opurdila@ixiacom.com>
Date: Tue, 28 Jul 2009 17:43:27 +0300
> On Monday 27 July 2009 18:26:44 David Miller wrote:
>
>> This benefits, at best, %0.000000001 of users of the Linux kernel,
>> because every distribution is going to turn on every single option.
>>
>
> Not all Linux users are using regular (desktop/server) distributions.
I didn't say all, I said "nearly all" which for many considerations
is roughly equivalent.
That %0.0000000001 was meant to represent non-distribution users.
^ permalink raw reply
* Re: [PATCH 2/2] c/r: Add AF_INET support (v3)
From: Oren Laadan @ 2009-07-28 17:22 UTC (permalink / raw)
To: John Dykstra; +Cc: Dan Smith, containers, netdev, Alexey Dobriyan
In-Reply-To: <1248468247.16746.12.camel@merlyn>
John Dykstra wrote:
> On Tue, 2009-07-07 at 12:26 -0700, Dan Smith wrote:
>> 2. I don't do anything to redirect or freeze traffic flowing to or from the
>> remote system (to prevent a RST from breaking things). I expect that
>> userspace will bring down a veth device or freeze traffic to the remote
>> system to handle this case.
>
> Theoretically, you can drop any packet that's in flight (ingress or
> egress), because IP doesn't guarantee delivery. TCP is able to recover,
> and a UDP or raw-socket application should already be designed to. Of
> course, retransmissions will have an impact on application performance
> in the migration case, so that's got to be considered in the tradeoff.
> Main goal should probably be avoiding anything that shoves either end
> into slow-start.
Sure. Still, the network needs to be blocked for the duration of the
migration to ensure that the socket at the origin does not ACK any
new data after the receive buffers have been saved.
>
> Thinking out loud, have you considered draining TCP buffers rather than
> including them in the checkpoint? You'd stop ingress traffic, and let
> the app run until it had read everything in the socket buffer. On the
> egress side, you'd cork the app by telling it that buffers were full,
> and then wait until the data already at the socket layer had been
> transmitted. Both are somewhat unbounded re time, and probably not
> worth it, but maybe there's some variant of this idea that has value.
> TCP transmit buffers on 10GE links can be pretty big...
Hmmm... buffers can be big, but I would expect that in most case the
memory footprint of the application will be bigger (unless all it
does is some very simple receive-filter-send of data).
Oren.
>
> BTW, if you see RSTs, that probably means you've created a protocol
> violation due to a buggy restore. Just blocking or dropping packets
> shouldn't result in an RST unless it's very long.
>
> -- John
>
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
^ permalink raw reply
* Re: [PATCH 2/2] c/r: Add AF_INET support (v3)
From: Oren Laadan @ 2009-07-28 17:07 UTC (permalink / raw)
To: Dan Smith; +Cc: John Dykstra, containers, netdev, Alexey Dobriyan
In-Reply-To: <874oswer21.fsf@caffeine.danplanet.com>
Dan Smith wrote:
> JD> I don't know whether this would affect palatibility (sic) for the
> JD> mainline, but it bothers me... socket.h (and sock.h) are included
> JD> all over the place in the kernel, and this definition is only
> JD> needed in very limited locations. Can it be placed in a .h used
> JD> only by checkpoint code?
>
> This was moved here based on previous comments on the patch.
> Personally, I think socket.h is a little too wide. While iterating on
> this patch locally, I've discovered that socket.h won't really work
> because in6.h includes it early and thus I'm unable to include some of
> the address structures as a result. I think going back to a
> checkpoint-specific header would be helpful.
>
> JD> There's an interesting design choice re TIME_WAIT and similar
> JD> states. In a migration scenario, do those sks migrate? If the
> JD> tree isn't going to be restored for a while., you want the
> JD> original host to continue to respond to those four-tuples If the
> JD> IP address of the original is immediately migrated to another
> JD> machine, you want the TIME_WAIT sks to migrate too.
>
> Well, as far as I'm concerned, the only sane migration scenario is one
> where you migrate the IP address and virtual interface with the
> task. When you destroy the virtual interface after (or during) the
> migration, the TIME_WAIT socket will disappear from the sending host.
Note that such sockets are unlikely to be referenced by _any_ process
because they will have been closed already. So the checkpoint code
will need to find such sockets not through file descriptors.
>
> I think that we need to increment timers like this on restore anyway,
> which should make sure that the TIME_WAIT timers run for the same
> amount of wall-clock time regardless of how much time was spent in the
> process of migration, right?
>
> Since checkpoint is not aware of a potential migration, a regular
> (i.e. not intended for migration) checkpoint operation on a task
> running in the init netns will leave the TIME_WAIT socket in place
> until the timer expires.
>
>>> +static int sock_inet_restart(struct ckpt_ctx *ctx,
>>> + struct ckpt_hdr_socket *h,
>>> + struct socket *socket)
>>> +{
>>> + int ret;
>>> + struct ckpt_hdr_socket_inet *in;
>>> + struct sockaddr_in *l = (struct sockaddr_in *)&h->laddr;
>>> +
>>> + in = ckpt_read_obj_type(ctx, sizeof(*in), CKPT_HDR_SOCKET_INET);
>>> + if (IS_ERR(in))
>>> + return PTR_ERR(in);
>>> +
>>> + /* Listening sockets and those that are closed but have a local
>>> + * address need to call bind()
>>> + */
>>> + if ((h->sock.state == TCP_LISTEN) ||
>>> + ((h->sock.state == TCP_CLOSE) && (h->laddr_len > 0))) {
>>> + socket->sk->sk_reuse = 2;
>>> + inet_sk(socket->sk)->freebind = 1;
>>> + ret = socket->ops->bind(socket,
>>> + (struct sockaddr *)l,
>>> + h->laddr_len);
>>> + ckpt_debug("inet bind: %i", ret);
>>> + if (ret < 0)
>>> + goto out;
>>> +
>>> + if (h->sock.state == TCP_LISTEN) {
>>> + ret = socket->ops->listen(socket, h->sock.backlog);
>>> + ckpt_debug("inet listen: %i", ret);
>>> + if (ret < 0)
>>> + goto out;
>>> +
>>> + ret = sock_add_parent(ctx, socket->sk);
>>> + if (ret < 0)
>>> + goto out;
>
> JD> So this is just dummied off as a proof-of-concept for LISTEN?
>
> I'm not sure what you mean...
>
>>> + }
>>> + } else {
>>> + ret = sock_cptrst(ctx, socket->sk, h, CKPT_RST);
>>> + if (ret)
>>> + goto out;
>>> +
>>> + ret = sock_inet_cptrst(ctx, socket->sk, in, CKPT_RST);
>>> + if (ret)
>>> + goto out;
>
> JD> At a minimum, you'll want to start the TCP retransmit timer if there is
> JD> unacknowledged data outstanding. And other timers for other states, as
> JD> they're supported.
>
> JD> And you probably do want to do slow-start again--disregard my babbling
> JD> from yesterday.
>
> Heh, okay :)
>
> JD> This is part of your AF_UNIX patch:
>
> JD> struct socket *do_sock_file_restore(struct ckpt_ctx *ctx,
> JD> struct ckpt_hdr_socket *h)
> JD> {
> JD> struct socket *socket;
> JD> int ret;
>
> JD> ret = sock_create(h->sock_common.family, h->sock.type, 0, &socket);
> JD> if (ret < 0)
> JD> return ERR_PTR(ret);
>
>
> JD> You _really_ want to pass the actual protocol number to sock_create().
> JD> The size of the sk it creates depends on this. You'll quickly be in
> JD> memory corruption hell without it.
>
> You mean I need to verify that the protocol is one of IPPROTO_TCP,
> IPPROTO_UDP, or PF_UNIX, right?
>
> JD> Also from the AF_UNIX patch:
>
> JD> static int obj_sock_users(void *ptr)
> JD> {
> JD> return atomic_read(&((struct sock *) ptr)->sk_refcnt);
> JD> }
>
> JD> Network sockets also use sk->sk_wmem_alloc to track references to
> JD> the sock from egress skb's
>
> IIUC, this function is part of the framework's leak detection. That
> code looks to make sure objects don't gain any additional users
> between the start and end of the checkpoint operation. I think the
> sk_refcnt satisfies that requirement here, no?
As I commented on patch 5/5 AF_UNIX -- IMO socket objects don't require
leak-detection, since they are 1-to-1 with files, which are already
accounted for. sockets can't be otherwise cloned/inherited/transferred
between processes.
>
> JD> And:
>
> JD> static int sock_copy_buffers(struct sk_buff_head *from, struct
> JD> sk_buff_head *to)
> JD> {
> JD> int count = 0;
> JD> struct sk_buff *skb;
>
> JD> skb_queue_walk(from, skb) {
> JD> struct sk_buff *tmp;
>
> JD> tmp = dev_alloc_skb(skb->len);
> JD> if (!tmp)
> JD> return -ENOMEM;
>
> JD> spin_lock(&from->lock);
> JD> skb_morph(tmp, skb);
> JD> spin_unlock(&from->lock);
>
> JD> Why not just clone the skb?
>
> Okay, good call.
>
> Thanks!
>
Oren.
^ permalink raw reply
* Re: [PATCH 1/2] IPVS: use pr_fmt
From: Joe Perches @ 2009-07-28 16:55 UTC (permalink / raw)
To: Hannes Eder; +Cc: lvs-devel, netdev, linux-kernel, Jan Engelhardt
In-Reply-To: <20090728160536.12503.82355.stgit@jazzy.zrh.corp.google.com>
On Tue, 2009-07-28 at 18:06 +0200, Hannes Eder wrote:
> While being at it cleanup whitespace.
> diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
> index e01cc2d..99f09ab 100644
> --- a/include/net/ip_vs.h
> +++ b/include/net/ip_vs.h
> @@ -99,47 +99,47 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
> return &buf[*idx - len];
> }
>
> -#define IP_VS_DBG_BUF(level, msg...) \
> - do { \
> - char ip_vs_dbg_buf[160]; \
> - int ip_vs_dbg_idx = 0; \
> - if (level <= ip_vs_get_debug_level()) \
> - printk(KERN_DEBUG "IPVS: " msg); \
> - } while (0)
[]
> +#define IP_VS_DBG_BUF(level, msg...) \
> + do { \
> + char ip_vs_dbg_buf[160]; \
> + int ip_vs_dbg_idx = 0; \
> + if (level <= ip_vs_get_debug_level()) \
> + pr_debug(msg); \
I think you should keep printk(KERN_DEBUG...) here and elsewhere.
Unless DEBUG is #defined, this won't print anything.
^ permalink raw reply
* Re: [PATCH 5/5] c/r: Add AF_UNIX support (v6)
From: Oren Laadan @ 2009-07-28 16:54 UTC (permalink / raw)
To: Dan Smith
Cc: containers-qjLDD68F18O7TbgM5vRIOg, netdev-u79uwXL29TY76Z2rM5mHXA,
Alexey Dobriyan
In-Reply-To: <1248295301-30930-6-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Hi Dan,
Dan Smith wrote:
> This patch adds basic checkpoint/restart support for AF_UNIX sockets. It
> has been tested with a single and multiple processes, and with data inflight
> at the time of checkpoint. It supports socketpair()s, path-based, and
> abstract sockets.
>
> Changes in v6:
> - Moved the socket addresses to the per-type header
> - Eliminated the HASCWD flag
> - Remove use of ckpt_write_err() in restart paths
> - Change the order in which buffers are read so that we can set the
> socket's limit equal to the size of the image's buffers (if appropriate)
> and then restore the original values afterwards.
> - Use the ckpt_validate_errno() helper
> - Add a check to make sure that we didn't restore a (UNIX) socket with
> any skb's in the send buffer
> - Fix up sock_unix_join() to not leave addr uninitialized for socketpair
> - Remove inclusion of checkpoint_hdr.h in the socket files
> - Make sock_unix_write_cwd() use ckpt_write_string() and use the new
> ckpt_read_string() for reading the cwd
> - Use the restored realcred credentials in sock_unix_join()
> - Fix error path of the chdir_and_bind
> - Change the algorithm for reloading the socket buffers to use sendmsg()
> on the socket's peer for better accounting
> - For DGRAM sockets, check the backlog value against the system max
> to avoid letting a restart bypass the overloaded queue length
> - Use sock_bind() instead of sock->ops->bind() to gain the security hook
> - Change "restart" to "restore" in some of the function names
>
> Changes in v5:
> - Change laddr and raddr buffers in socket header to be long enough
> for INET6 addresses
> - Place socket.c and sock.h function definitions inside #ifdef
> CONFIG_CHECKPOINT
> - Add explicit check in sock_unix_makeaddr() to refuse if the
> checkpoint image specifies an addr length of 0
> - Split sock_unix_restart() into a few pieces to facilitate:
> - Changed behavior of the unix restore code so that unlinked LISTEN
> sockets don't do a bind()...unlink()
> - Save the base path of a bound socket's path so that we can chdir()
> to the base before bind() if it is a relative path
> - Call bind() for any socket that is not established but has a
> non-zero-length local address
> - Enforce the current sysctl limit on socket buffer size during restart
> unless the user holds CAP_NET_ADMIN
> - Unlink a path-based socket before calling bind()
[...]
> +static int obj_sock_grab(void *ptr)
> +{
> + sock_hold((struct sock *) ptr);
> + return 0;
> +}
> +
> +static void obj_sock_drop(void *ptr)
> +{
> + sock_put((struct sock *) ptr);
> +}
> +
> +static int obj_sock_users(void *ptr)
> +{
> + return atomic_read(&((struct sock *) ptr)->sk_refcnt);
> +}
> +
obj_sock_users() is only required for objects that are to be
tested for leaks in full container checkpoint. I don't think
it's needed, because the relation sock <-> file is 1-to-1.
(If it were, then you would also need to collect sockets).
> static struct ckpt_obj_ops ckpt_obj_ops[] = {
> /* ignored object */
> {
> @@ -367,6 +384,16 @@ static struct ckpt_obj_ops ckpt_obj_ops[] = {
> .checkpoint = checkpoint_groupinfo,
> .restore = restore_groupinfo,
> },
> + /* sock object */
> + {
> + .obj_name = "SOCKET",
> + .obj_type = CKPT_OBJ_SOCK,
> + .ref_drop = obj_sock_drop,
> + .ref_grab = obj_sock_grab,
> + .ref_users = obj_sock_users,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scratch this one
> + .checkpoint = sock_file_checkpoint,
> + .restore = sock_file_restore,
These two should be 'checkpoint_bad' and 'restore_bad' respsectively.
Sockets are handled via files, not as independent objects.
(Actually, I will remove checkpoint_bad and restore_bad and modify
checkpoint_obj() and restore_obj() to fail if the respective method
is NULL).
> + },
> };
>
>
> diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h
> index 8b7ca46..e542ff5 100644
> --- a/include/linux/checkpoint_hdr.h
> +++ b/include/linux/checkpoint_hdr.h
> @@ -88,6 +88,12 @@ enum {
>
> CKPT_HDR_SIGHAND = 601,
>
> + CKPT_HDR_FD_SOCKET = 701,
> + CKPT_HDR_SOCKET,
> + CKPT_HDR_SOCKET_BUFFERS,
> + CKPT_HDR_SOCKET_BUFFER,
Nit: I already got confused a few times because of the similar names.
Perhaps change CKPT_HDR_SOCKET_BUFFERS to CKPT_HDR_SOCKET_QUEUE (and
adjust the header name accordingly).
> + CKPT_HDR_SOCKET_UNIX,
> +
> CKPT_HDR_TAIL = 9001,
>
> CKPT_HDR_ERROR = 9999,
> @@ -122,6 +128,7 @@ enum obj_type {
> CKPT_OBJ_CRED,
> CKPT_OBJ_USER,
> CKPT_OBJ_GROUPINFO,
> + CKPT_OBJ_SOCK,
> CKPT_OBJ_MAX
> };
>
> @@ -326,6 +333,7 @@ enum file_type {
> CKPT_FILE_IGNORE = 0,
> CKPT_FILE_GENERIC,
> CKPT_FILE_PIPE,
> + CKPT_FILE_SOCKET,
> CKPT_FILE_MAX
> };
>
> @@ -349,6 +357,11 @@ struct ckpt_hdr_file_pipe {
> __s32 pipe_objref;
> } __attribute__((aligned(8)));
>
> +struct ckpt_hdr_file_socket {
> + struct ckpt_hdr_file common;
> + __u16 family;
> +} __attribute__((aligned(8)));
> +
> struct ckpt_hdr_file_pipe_state {
> struct ckpt_hdr h;
> __s32 pipe_len;
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 3b461df..cd675dd 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -23,6 +23,7 @@ struct __kernel_sockaddr_storage {
> #include <linux/uio.h> /* iovec support */
> #include <linux/types.h> /* pid_t */
> #include <linux/compiler.h> /* __user */
> +#include <linux/checkpoint.h> /* struct ckpt_hdr */
>
> #ifdef __KERNEL__
> # ifdef CONFIG_PROC_FS
> @@ -328,5 +329,67 @@ extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *ka
> extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
>
> #endif
> +
> +#ifdef CONFIG_CHECKPOINT
> +#include <linux/un.h> /* sockaddr_un */
Unless/until we decide otherwise, let's keep all ckpt_hdr_xxx
definitions in a single place -- checkpoint_hdr.h
> +
> +#define CKPT_UNIX_LINKED 1
> +struct ckpt_hdr_socket_unix {
> + struct ckpt_hdr h;
> + __u32 this;
> + __u32 peer;
For objrefs please use __s32.
> + __u32 flags;
> + __u32 laddr_len;
> + __u32 raddr_len;
> + struct sockaddr_un laddr;
> + struct sockaddr_un raddr;
> +} __attribute__ ((aligned(8)));
> +
> +struct ckpt_hdr_socket {
> + struct ckpt_hdr h;
> +
> + struct ckpt_socket { /* struct socket */
Unless you intend to use the struct name 'ckpt_socket' elsewhere,
can we get rid of it (leaving only 'struct {') ?
> + __u64 flags;
> + __u8 state;
> + } socket __attribute__ ((aligned(8)));
> +
> + struct ckpt_sock_common { /* struct sock_common */
Here too.
> + __u32 bound_dev_if;
> + __u16 family;
> + __u8 state;
> + __u8 reuse;
> + } sock_common __attribute__ ((aligned(8)));
> +
> + struct ckpt_sock { /* struct sock */
And here.
> + __s64 rcvlowat;
> + __s64 rcvtimeo;
> + __s64 sndtimeo;
> + __u64 flags;
> + __u64 lingertime;
> +
> + __u32 err;
> + __u32 err_soft;
> + __u32 priority;
> + __s32 rcvbuf;
> + __s32 sndbuf;
> + __u16 type;
> + __s16 backlog;
> +
> + __u8 protocol;
> + __u8 state;
> + __u8 shutdown;
> + __u8 userlocks;
> + __u8 no_check;
> + } sock __attribute__ ((aligned(8)));
> +
> +} __attribute__ ((aligned(8)));
> +
> +struct ckpt_hdr_socket_buffer {
> + struct ckpt_hdr h;
> + __u32 skb_count;
> + __u32 total_bytes;
> +} __attribute__ ((aligned(8)));
> +#endif /* CONFIG_CHECKPOINT */
> +
> #endif /* not kernel and not glibc */
> #endif /* _LINUX_SOCKET_H */
> diff --git a/include/net/sock.h b/include/net/sock.h
> index d435dc1..4043cd2 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -1608,4 +1608,15 @@ extern int sysctl_optmem_max;
> extern __u32 sysctl_wmem_default;
> extern __u32 sysctl_rmem_default;
>
> +#ifdef CONFIG_CHECKPOINT
> +/* Checkpoint/Restart Functions */
> +struct ckpt_ctx;
> +struct ckpt_hdr_socket;
> +extern int sock_file_checkpoint(struct ckpt_ctx *, void *);
> +extern void *sock_file_restore(struct ckpt_ctx *);
> +extern struct socket *do_sock_file_restore(struct ckpt_ctx *,
> + struct ckpt_hdr_socket *);
> +extern int do_sock_file_checkpoint(struct ckpt_ctx *ctx, struct file *file);
> +#endif
> +
> #endif /* _SOCK_H */
> diff --git a/net/Makefile b/net/Makefile
> index ba324ae..91d12fe 100644
> --- a/net/Makefile
> +++ b/net/Makefile
> @@ -66,3 +66,5 @@ ifeq ($(CONFIG_NET),y)
> obj-$(CONFIG_SYSCTL) += sysctl_net.o
> endif
> obj-$(CONFIG_WIMAX) += wimax/
> +
> +obj-$(CONFIG_CHECKPOINT) += checkpoint.o
> diff --git a/net/checkpoint.c b/net/checkpoint.c
> new file mode 100644
> index 0000000..748d3aa
> --- /dev/null
> +++ b/net/checkpoint.c
> @@ -0,0 +1,779 @@
> +/*
> + * Copyright 2009 IBM Corporation
> + *
> + * Author: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation, version 2 of the
> + * License.
> + */
> +
> +#include <linux/socket.h>
> +#include <linux/mount.h>
> +#include <linux/file.h>
> +#include <linux/namei.h>
> +#include <linux/syscalls.h>
> +#include <linux/sched.h>
> +#include <linux/fs_struct.h>
> +
> +#include <net/af_unix.h>
> +#include <net/tcp_states.h>
> +
> +#include <linux/checkpoint.h>
> +#include <linux/checkpoint_hdr.h>
> +
> +#define UNIX_ADDR_EMPTY(a) (a <= sizeof(short))
> +
> +static inline int sock_unix_need_cwd(struct sockaddr_un *addr,
> + unsigned long len)
> +{
> + return (!UNIX_ADDR_EMPTY(len)) &&
> + addr->sun_path[0] &&
> + (addr->sun_path[0] != '/');
> +}
> +
> +static int sock_copy_buffers(struct sk_buff_head *from,
> + struct sk_buff_head *to,
> + uint32_t *total_bytes)
> +{
> + int count = 0;
> + struct sk_buff *skb;
> +
> + *total_bytes = 0;
> +
> + skb_queue_walk(from, skb) {
> + struct sk_buff *tmp;
> +
> + tmp = dev_alloc_skb(skb->len);
> + if (!tmp)
> + return -ENOMEM;
> +
> + spin_lock(&from->lock);
> + skb_morph(tmp, skb);
> + spin_unlock(&from->lock);
> +
> + skb_queue_tail(to, tmp);
> + count++;
> + *total_bytes += tmp->len;
> + }
> +
> + return count;
> +}
> +
> +static int __sock_write_buffers(struct ckpt_ctx *ctx,
> + struct sk_buff_head *queue)
> +{
> + struct sk_buff *skb;
> + int ret = 0;
> +
> + skb_queue_walk(queue, skb) {
> + if (UNIXCB(skb).fp) {
> + ckpt_write_err(ctx, "fd-passing is not supported");
> + return -EBUSY;
> + }
> +
> + ret = ckpt_write_obj_type(ctx, skb->data, skb->len,
> + CKPT_HDR_SOCKET_BUFFER);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static int sock_write_buffers(struct ckpt_ctx *ctx, struct sk_buff_head *queue)
> +{
> + struct ckpt_hdr_socket_buffer *h;
> + struct sk_buff_head tmpq;
> + int ret = -ENOMEM;
> +
> + h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_SOCKET_BUFFERS);
> + if (!h)
> + goto out;
> +
> + skb_queue_head_init(&tmpq);
> +
> + h->skb_count = sock_copy_buffers(queue, &tmpq, &h->total_bytes);
> + if (h->skb_count < 0) {
h->skb_count is unsigned...
> + ret = h->skb_count;
> + goto out;
> + }
> +
> + ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
> + if (!ret)
> + ret = __sock_write_buffers(ctx, &tmpq);
> +
> + out:
> + ckpt_hdr_put(ctx, h);
> + __skb_queue_purge(&tmpq);
> +
> + return ret;
> +}
> +
> +static int sock_unix_write_cwd(struct ckpt_ctx *ctx,
> + struct sock *sock,
> + const char *sockpath)
> +{
> + struct path path;
> + char *buf;
> + char *fqpath;
> + int offset;
> + int ret = -ENOENT;
> +
> + buf = kmalloc(PATH_MAX, GFP_KERNEL);
> + if (!buf)
> + return -ENOMEM;
> +
> + path.dentry = unix_sk(sock)->dentry;
> + path.mnt = unix_sk(sock)->mnt;
> +
> + fqpath = d_path(&path, buf, PATH_MAX);
> + if (!fqpath)
> + goto out;
Can you use fill_name() from checkpoint/file.c ? rename it to
ckpt_fill_name() or something when you export it.
> +
> + offset = strlen(fqpath) - strlen(sockpath);
> + if (offset <= 0) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + fqpath[offset] = '\0';
> +
> + ckpt_debug("writing socket directory: %s\n", fqpath);
> + ret = ckpt_write_string(ctx, fqpath, strlen(fqpath));
> + out:
> + kfree(buf);
> + return ret;
> +}
> +
> +static int sock_unix_getnames(struct ckpt_ctx *ctx,
> + struct ckpt_hdr_socket_unix *un,
> + struct socket *socket)
> +{
> + struct sockaddr *loc = (struct sockaddr *)&un->laddr;
> + struct sockaddr *rem = (struct sockaddr *)&un->raddr;
> +
> + if (socket->ops->getname(socket, loc, &un->laddr_len, 0)) {
> + ckpt_write_err(ctx, "Unable to getname of local");
> + return -EINVAL;
> + }
This direct call to ->getname skips security checks through
getsockname(). You may want to refactor sys_getsockname() similar
to sys_bind().
> +
> + if (socket->ops->getname(socket, rem, &un->raddr_len, 1)) {
> + if ((socket->sk->sk_type != SOCK_DGRAM) &&
> + (socket->sk->sk_state == TCP_ESTABLISHED)) {
> + ckpt_write_err(ctx, "Unable to getname of remote");
> + return -EINVAL;
> + }
And here it skips security checks through sys_getppername().
> + un->raddr_len = 0;
> + }
> +
> + return 0;
> +}
> +
> +static int sock_unix_checkpoint(struct ckpt_ctx *ctx,
> + struct socket *socket,
> + struct ckpt_hdr_socket *h)
> +{
> + struct unix_sock *sk = unix_sk(socket->sk);
> + struct unix_sock *pr = unix_sk(sk->peer);
> + struct ckpt_hdr_socket_unix *un;
> + int new;
> + int ret = -ENOMEM;
> +
> + if ((socket->sk->sk_state == TCP_LISTEN) &&
> + !skb_queue_empty(&socket->sk->sk_receive_queue)) {
> + ckpt_write_err(ctx, "listening socket has unaccepted peers");
> + return -EBUSY;
> + }
> +
> + un = ckpt_hdr_get_type(ctx, sizeof(*un), CKPT_HDR_SOCKET_UNIX);
> + if (!un)
> + goto out;
> +
> + ret = sock_unix_getnames(ctx, un, socket);
> + if (ret)
> + goto out;
> +
> + if (sk->dentry && (sk->dentry->d_inode->i_nlink > 0))
> + un->flags |= CKPT_UNIX_LINKED;
> +
> + un->this = ckpt_obj_lookup_add(ctx, sk, CKPT_OBJ_SOCK, &new);
> + if (un->this < 0)
> + goto out;
un->this is unsigned... but the real fix is to make un->this __s32
as noted above.
> +
> + if (sk->peer)
> + un->peer = ckpt_obj_lookup_add(ctx, pr, CKPT_OBJ_SOCK, &new);
> + else
> + un->peer = 0;
> +
> + if (un->peer < 0) {
ditto.
> + ret = un->peer;
> + goto out;
> + }
> +
> + ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
> + if (ret < 0)
> + goto out;
> +
> + ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) un);
> + if (ret < 0)
> + goto out;
> +
> + if (sock_unix_need_cwd(&un->laddr, un->laddr_len))
> + ret = sock_unix_write_cwd(ctx, socket->sk, un->laddr.sun_path);
> + out:
> + ckpt_hdr_put(ctx, un);
> +
> + return ret;
> +}
> +
> +static int sock_cptrst_verify(struct ckpt_hdr_socket *h)
> +{
> + uint8_t userlocks_mask = SOCK_SNDBUF_LOCK | SOCK_RCVBUF_LOCK |
> + SOCK_BINDADDR_LOCK | SOCK_BINDPORT_LOCK;
> +
> + if (h->sock.shutdown & ~SHUTDOWN_MASK)
> + return -EINVAL;
> + if (h->sock.userlocks & ~userlocks_mask)
> + return -EINVAL;
> + if (h->sock.sndtimeo < 0)
> + return -EINVAL;
> + if (h->sock.rcvtimeo < 0)
> + return -EINVAL;
Forgot sock.rcvlowat ?
> + if ((h->sock.userlocks & SOCK_SNDBUF_LOCK) &&
> + ((h->sock.sndbuf < SOCK_MIN_SNDBUF) ||
> + (h->sock.sndbuf > sysctl_wmem_max)))
> + return -EINVAL;
At least for afunix, if the user did not explicitly set the sndbuf,
then userlocks won't have SOCK_SNDBUF_LOCK set.
Also, if userlocks in the image doesn't have SOCK_SNDBUF_LOCK, then
the sndbuf value isn't checked ?
> + if ((h->sock.userlocks & SOCK_RCVBUF_LOCK) &&
> + ((h->sock.rcvbuf < SOCK_MIN_RCVBUF) ||
> + (h->sock.rcvbuf > sysctl_rmem_max)))
> + return -EINVAL;
ditto.
> + if ((h->sock.flags & SOCK_LINGER) &&
> + (h->sock.lingertime > MAX_SCHEDULE_TIMEOUT))
> + return -EINVAL;
Regardless of SOCK_LINGER flag, lingertime should never exceed that
maximum value.
What about verifying sock.flags itself ?
In doing that, some options may assume/require some state --
- SOCK_USE_WRITE_QUEUE only used in ipv4/ipv6/sctp
- SOCK_DESTROY only used in some protocols
Perhaps sanitize sock.flags per protocol ?
> + if (!ckpt_validate_errno(h->sock.err))
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> +static int sock_cptrst(struct ckpt_ctx *ctx,
> + struct sock *sock,
> + struct ckpt_hdr_socket *h,
> + int op)
> +{
> + if (sock->sk_socket) {
> + CKPT_COPY(op, h->socket.flags, sock->sk_socket->flags);
> + CKPT_COPY(op, h->socket.state, sock->sk_socket->state);
> + }
> +
> + CKPT_COPY(op, h->sock_common.reuse, sock->sk_reuse);
> + CKPT_COPY(op, h->sock_common.bound_dev_if, sock->sk_bound_dev_if);
> + CKPT_COPY(op, h->sock_common.family, sock->sk_family);
> +
> + CKPT_COPY(op, h->sock.shutdown, sock->sk_shutdown);
> + CKPT_COPY(op, h->sock.userlocks, sock->sk_userlocks);
> + CKPT_COPY(op, h->sock.no_check, sock->sk_no_check);
> + CKPT_COPY(op, h->sock.protocol, sock->sk_protocol);
> + CKPT_COPY(op, h->sock.err, sock->sk_err);
> + CKPT_COPY(op, h->sock.err_soft, sock->sk_err_soft);
> + CKPT_COPY(op, h->sock.priority, sock->sk_priority);
> + CKPT_COPY(op, h->sock.rcvlowat, sock->sk_rcvlowat);
> + CKPT_COPY(op, h->sock.backlog, sock->sk_max_ack_backlog);
> + CKPT_COPY(op, h->sock.rcvtimeo, sock->sk_rcvtimeo);
> + CKPT_COPY(op, h->sock.sndtimeo, sock->sk_sndtimeo);
> + CKPT_COPY(op, h->sock.rcvbuf, sock->sk_rcvbuf);
> + CKPT_COPY(op, h->sock.sndbuf, sock->sk_sndbuf);
> + CKPT_COPY(op, h->sock.flags, sock->sk_flags);
> + CKPT_COPY(op, h->sock.lingertime, sock->sk_lingertime);
> + CKPT_COPY(op, h->sock.type, sock->sk_type);
> + CKPT_COPY(op, h->sock.state, sock->sk_state);
Many of these direct copy into the socket and sock effectively
bypass security checks that take place in {get,set}sockopt(),
either explicitly (e.g. sk_sndtimeo) or implicitly (e.g.
SOCK_LINGER in sock.flags, reflecting SO_LINGER option).
This applies both to checkpoint (potentially bypassing permission
of the checkpointer to view this data) and restart (bypassing
permissions of user to set these values).
The alternative is to use socksetopt/sockgetopt for those
values that should be subject to security checks.
> +
> + if ((h->socket.state == SS_CONNECTED) &&
> + (h->sock.state != TCP_ESTABLISHED)) {
> + ckpt_debug("socket/sock in inconsistent state: %i/%i",
> + h->socket.state, h->sock.state);
> + return -EINVAL;
There should also be per-protocol consistency checks. E.g. afunix
cannot be in socket.state == SS_{DIS,}CONNECTING
> + } else if ((h->sock.state < TCP_ESTABLISHED) ||
> + (h->sock.state >= TCP_MAX_STATES)) {
> + ckpt_debug("sock in invalid state: %i", h->sock.state);
> + return -EINVAL;
> + } else if ((h->socket.state < SS_FREE) ||
> + (h->socket.state > SS_DISCONNECTING)) {
> + ckpt_debug("socket in invalid state: %i",
> + h->socket.state);
> + return -EINVAL;
> + }
> +
> + if (op == CKPT_CPT)
> + return sock_cptrst_verify(h);
> + else
> + return 0;
> +}
> +
> +int do_sock_file_checkpoint(struct ckpt_ctx *ctx, struct file *file)
> +{
> + struct socket *socket = file->private_data;
> + struct sock *sock = socket->sk;
> + struct ckpt_hdr_socket *h;
> + int ret = 0;
> +
> + h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_SOCKET);
> + if (!h)
> + return -ENOMEM;
> +
> + ret = sock_cptrst(ctx, sock, h, CKPT_CPT);
> + if (ret)
> + goto out;
> +
> + if (sock->sk_family == AF_UNIX) {
> + ret = sock_unix_checkpoint(ctx, socket, h);
> + if (ret)
> + goto out;
> + } else {
> + ckpt_write_err(ctx, "unsupported socket family %i",
> + sock->sk_family);
> + ret = EINVAL;
^^^^
- !!!
Better yet: -ENOSYS ?
> + goto out;
> + }
> +
> + if (sock->sk_state != TCP_LISTEN) {
> + ret = sock_write_buffers(ctx, &sock->sk_receive_queue);
> + if (ret)
> + goto out;
> +
> + ret = sock_write_buffers(ctx, &sock->sk_write_queue);
> + if (ret)
> + goto out;
> + }
> + out:
> + ckpt_hdr_put(ctx, h);
> +
> + return ret;
> +}
> +
> +static int sock_read_buffer(struct ckpt_ctx *ctx, struct sock *sock)
> +{
> + struct ckpt_hdr h;
> + struct msghdr msg;
> + struct kvec kvec;
> + int ret = 0;
> + int len;
> +
> + memset(&msg, 0, sizeof(msg));
> +
> + len = _ckpt_read_hdr_type(ctx, &h, CKPT_HDR_SOCKET_BUFFER);
> + if (len < 0)
> + return len;
> +
> + if (len > SKB_MAX_ALLOC) {
> + ckpt_debug("Socket buffer too big (%i > %lu)",
> + len, SKB_MAX_ALLOC);
> + return -ENOSPC;
> + }
> +
> + kvec.iov_len = len;
> + kvec.iov_base = kmalloc(len, GFP_KERNEL);
> + if (!kvec.iov_base)
> + return -ENOMEM;
> +
> + ret = _ckpt_read_payload(ctx, &h, kvec.iov_base);
> + if (ret < 0)
> + goto out;
> +
> + ret = kernel_sendmsg(sock->sk_socket, &msg, &kvec, 1, len);
Is it possible to avoid the extra copy using splice() instead ?
> + ckpt_debug("kernel_sendmsg(%i): %i\n", len, ret);
> + if ((ret > 0) && (ret != len))
> + ret = -ENOMEM;
> + out:
> + return ret;
> +}
> +
> +static int sock_read_buffers(struct ckpt_ctx *ctx, struct sock *sock,
> + uint32_t *bufsize)
> +{
> + struct ckpt_hdr_socket_buffer *h;
> + int ret = 0;
> + int i;
> + uint32_t total = 0;
> + uint8_t sock_shutdown;
> +
> + /* If peer is shutdown, unshutdown it for this process */
> + sock_shutdown = sock->sk_shutdown;
> + sock->sk_shutdown &= ~SHUTDOWN_MASK;
SOCK_DEAD in sk->flags may also pose a problem.
(Do we at all need to checkpoint and/or restore SOCK_DEAD ?!)
> +
> + h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_SOCKET_BUFFERS);
> + if (IS_ERR(h)) {
> + ret = PTR_ERR(h);
> + goto out;
> + }
> +
> + if (!bufsize) {
> + if (h->total_bytes != 0) {
> + ckpt_debug("Expected empty buffer, got %u\n",
> + h->total_bytes);
> + ret = -EINVAL;
> + }
> + goto out;
> + } else if (h->total_bytes > *bufsize) {
> + if (capable(CAP_NET_ADMIN))
> + *bufsize = h->total_bytes;
Hmm... this test is quite hidden here - maybe a fat comment
with a reference to why it's here and what it is doing ?
> + else {
> + ckpt_debug("Buffer total %u exceeds limit %u\n",
> + h->total_bytes, *bufsize);
> + ret = -EINVAL;
> + goto out;
> + }
> + }
> +
> + for (i = 0; i < h->skb_count; i++) {
> + ret = sock_read_buffer(ctx, sock);
> + ckpt_debug("read buffer %i: %i\n", i, ret);
> + if (ret < 0)
> + break;
> +
> + total += ret;
> + if (total > h->total_bytes) {
What if 'total' overflows (for CAP_NET_ADMIN) ? perhaps:
if (total > h->total_bytes || total < ret) {
> + ckpt_debug("Buffers exceeded claimed %u", total);
> + ret = -EINVAL;
> + goto out;
> + }
> + }
> +
> + if (total == h->total_bytes)
> + ret = 0;
> + else {
> + ckpt_debug("Inconsistent total buffer size %u != %u\n",
> + total, h->total_bytes);
> + ret = -EINVAL;
> + }
> + out:
> + sock->sk_shutdown = sock_shutdown;
> + ckpt_hdr_put(ctx, h);
> +
> + return ret;
> +}
> +
> +static struct unix_address *sock_unix_makeaddr(struct sockaddr_un *sun_addr,
> + unsigned len)
> +{
> + struct unix_address *addr;
> +
> + if (len > sizeof(struct sockaddr_un))
> + return ERR_PTR(-EINVAL);
> +
> + addr = kmalloc(sizeof(*addr) + len, GFP_KERNEL);
> + if (!addr)
> + return ERR_PTR(-ENOMEM);
> +
> + memcpy(addr->name, sun_addr, len);
> + addr->len = len;
> + atomic_set(&addr->refcnt, 1);
> +
> + return addr;
> +}
> +
> +static int sock_unix_join(struct ckpt_ctx *ctx,
> + struct sock *a,
> + struct sock *b,
> + struct ckpt_hdr_socket_unix *un)
> +{
> + struct unix_address *addr = NULL;
> +
> + sock_hold(a);
> + sock_hold(b);
> +
> + unix_sk(a)->peer = b;
> + unix_sk(b)->peer = a;
> +
> + a->sk_peercred.pid = task_tgid_vnr(current);
> + a->sk_peercred.uid = ctx->realcred->uid;
> + a->sk_peercred.gid = ctx->realcred->gid;
> +
> + b->sk_peercred.pid = a->sk_peercred.pid;
> + b->sk_peercred.uid = a->sk_peercred.uid;
> + b->sk_peercred.gid = a->sk_peercred.gid;
> +
Does the following bypass security checks for sys_connect() ?
> + if (!UNIX_ADDR_EMPTY(un->raddr_len))
> + addr = sock_unix_makeaddr(&un->raddr, un->raddr_len);
> + else if (!UNIX_ADDR_EMPTY(un->laddr_len))
> + addr = sock_unix_makeaddr(&un->laddr, un->laddr_len);
> +
> + if (IS_ERR(addr))
> + return PTR_ERR(addr);
> + else if (addr) {
> + atomic_inc(&addr->refcnt); /* Held by both ends */
> + unix_sk(a)->addr = unix_sk(b)->addr = addr;
> + }
> +
> + return 0;
> +}
> +
> +static int sock_unix_restore_connected(struct ckpt_ctx *ctx,
> + struct ckpt_hdr_socket *h,
> + struct ckpt_hdr_socket_unix *un,
> + struct socket *socket)
> +{
> + struct sock *this = ckpt_obj_fetch(ctx, un->this, CKPT_OBJ_SOCK);
> + struct sock *peer = ckpt_obj_fetch(ctx, un->peer, CKPT_OBJ_SOCK);
> + struct socket *tmp = NULL;
> + int ret;
> +
> + if (!IS_ERR(this) && !IS_ERR(peer)) {
> + /* We're last */
> + struct socket *old = this->sk_socket;
> +
> + old->sk = NULL;
> + sock_release(old);
> + sock_graft(this, socket);
> +
> + } else if ((PTR_ERR(this) == -EINVAL) && (PTR_ERR(peer) == -EINVAL)) {
> + /* We're first */
> + int family = socket->sk->sk_family;
> + int type = socket->sk->sk_type;
> +
> + ret = sock_create(family, type, 0, &tmp);
> + ckpt_debug("sock_create: %i\n", ret);
> + if (ret)
> + goto out;
> +
> + this = socket->sk;
> + peer = tmp->sk;
> +
> + ret = ckpt_obj_insert(ctx, this, un->this, CKPT_OBJ_SOCK);
> + if (ret < 0)
> + goto out;
> +
> + ret = ckpt_obj_insert(ctx, peer, un->peer, CKPT_OBJ_SOCK);
> + if (ret < 0)
> + goto out;
> +
> + ret = sock_unix_join(ctx, this, peer, un);
> + ckpt_debug("sock_unix_join: %i\n", ret);
> + if (ret)
> + goto out;
> +
> + } else {
> + ckpt_debug("Order Error\n");
> + ret = PTR_ERR(this);
> + goto out;
> + }
> +
> + /* Prime the socket's buffer limit with the maximum */
> + peer->sk_userlocks |= SOCK_SNDBUF_LOCK;
> + peer->sk_sndbuf = sysctl_wmem_max;
I suppose this meant to be temporary ?
> +
> + /* Read my buffers and sendmsg() then back to me via my peer */
> + ret = sock_read_buffers(ctx, peer, &peer->sk_sndbuf);
> + ckpt_debug("sock_read_buffers: %i\n", ret);
> + if (ret)
> + goto out;
> +
> + /* Read peer's buffers and expect 0 */
> + ret = sock_read_buffers(ctx, peer, NULL);
It is indeed a good idea to make it generic for all sockets, but I
suspect the way sock_read_buffers() works will only be suitable for
afunix, and perhaps for in-container inet4/6 (by "in-container" I
mean that both sides of the connection are in the checkpoint image).
> + out:
> + if (tmp && ret)
> + sock_release(tmp);
> +
> + return ret;
> +}
> +
> +static int sock_unix_unlink(const char *name)
> +{
> + struct path spath;
> + struct path ppath;
> + int ret;
> +
> + ret = kern_path(name, 0, &spath);
> + if (ret)
> + return ret;
> +
> + ret = kern_path(name, LOOKUP_PARENT, &ppath);
> + if (ret)
> + goto out_s;
> +
> + if (!spath.dentry) {
> + ckpt_debug("No dentry found for %s\n", name);
> + ret = -ENOENT;
> + goto out_p;
> + }
> +
> + if (!ppath.dentry || !ppath.dentry->d_inode) {
> + ckpt_debug("No inode for parent of %s\n", name);
> + ret = -ENOENT;
> + goto out_p;
> + }
> +
> + ret = vfs_unlink(ppath.dentry->d_inode, spath.dentry);
> + out_p:
> + path_put(&ppath);
> + out_s:
> + path_put(&spath);
> +
> + return ret;
> +}
> +
> +/* Call bind() for socket, optionally changing (temporarily) to @path first
> + * if non-NULL
> + */
> +static int sock_unix_chdir_and_bind(struct socket *socket,
> + const char *path,
> + struct sockaddr *addr,
> + unsigned long addrlen)
> +{
> + struct sockaddr_un *un = (struct sockaddr_un *)addr;
> + int ret;
> + struct path cur;
> + struct path dir;
> +
> + if (path) {
> + ckpt_debug("switching to cwd %s for unix bind", path);
> +
> + ret = kern_path(path, 0, &dir);
> + if (ret)
> + return ret;
> +
> + ret = inode_permission(dir.dentry->d_inode,
> + MAY_EXEC | MAY_ACCESS);
> + if (ret)
> + goto out;
> +
> + write_lock(¤t->fs->lock);
> + cur = current->fs->pwd;
> + current->fs->pwd = dir;
> + write_unlock(¤t->fs->lock);
> + }
> +
> + ret = sock_unix_unlink(un->sun_path);
> + ckpt_debug("unlink(%s): %i\n", un->sun_path, ret);
> + if ((ret == 0) || (ret == -ENOENT))
> + ret = sock_bind(socket, addr, addrlen);
> +
> + if (path) {
> + write_lock(¤t->fs->lock);
> + current->fs->pwd = cur;
> + write_unlock(¤t->fs->lock);
> + }
> + out:
> + if (path)
> + path_put(&dir);
> +
> + return ret;
> +}
> +
> +static int sock_unix_fakebind(struct socket *socket,
> + struct sockaddr_un *addr,
> + unsigned long len)
> +{
> + struct unix_address *uaddr;
> +
> + uaddr = sock_unix_makeaddr(addr, len);
> + if (IS_ERR(uaddr))
> + return PTR_ERR(uaddr);
> +
> + unix_sk(socket->sk)->addr = uaddr;
> +
> + return 0;
> +}
> +
> +static int sock_unix_bind(struct ckpt_hdr_socket *h,
> + struct ckpt_hdr_socket_unix *un,
> + struct socket *socket,
> + const char *path)
> +{
> + struct sockaddr *addr = (struct sockaddr *)&un->laddr;
> + unsigned long len = un->laddr_len;
> +
> + if (!un->laddr.sun_path[0])
> + return sock_bind(socket, addr, len);
> + else if (!(un->flags & CKPT_UNIX_LINKED))
> + return sock_unix_fakebind(socket, &un->laddr, len);
> + else
> + return sock_unix_chdir_and_bind(socket, path, addr, len);
> +}
> +
> +static int sock_unix_restore(struct ckpt_ctx *ctx,
> + struct ckpt_hdr_socket *h,
> + struct socket *socket)
> +{
> + struct ckpt_hdr_socket_unix *un;
> + int ret = -EINVAL;
> + char *cwd = NULL;
> + struct net *net = sock_net(socket->sk);
> +
> + /* AF_UNIX overloads the backlog setting to define the maximum
> + * queue length for DGRAM sockets. Make sure we don't let the
> + * caller exceed that value on restart.
> + */
> + if ((h->sock.type == SOCK_DGRAM) &&
> + (h->sock.backlog > net->unx.sysctl_max_dgram_qlen)) {
> + ckpt_debug("DGRAM backlog of %i exceeds system max of %i\n",
> + h->sock.backlog, net->unx.sysctl_max_dgram_qlen);
> + return -EINVAL;
> + }
> +
> + un = ckpt_read_obj_type(ctx, sizeof(*un), CKPT_HDR_SOCKET_UNIX);
> + if (IS_ERR(un))
> + return PTR_ERR(un);
> +
> + if (un->peer < 0)
> + goto out;
> +
> + if (sock_unix_need_cwd(&un->laddr, un->laddr_len)) {
> + ret = ckpt_read_string(ctx, &cwd, PATH_MAX);
> + ckpt_debug("read cwd(%i): %s\n", ret, cwd);
> + if (ret)
> + goto out;
> + }
> +
> + if ((h->sock.state != TCP_ESTABLISHED) &&
> + !UNIX_ADDR_EMPTY(un->laddr_len)) {
> + ret = sock_unix_bind(h, un, socket, cwd);
> + if (ret)
> + goto out;
> + }
> +
Hmm... does the code below work well with dgram sockets who received
data from the peer, and then the peer died (before checkpoint) ?
> + if ((h->sock.state == TCP_ESTABLISHED) || (h->sock.state == TCP_CLOSE))
> + ret = sock_unix_restore_connected(ctx, h, un, socket);
> + else if (h->sock.state == TCP_LISTEN)
> + ret = socket->ops->listen(socket, h->sock.backlog);
> + else
> + ckpt_debug("unsupported UNIX socket state %i\n", h->sock.state);
> + out:
> + ckpt_hdr_put(ctx, un);
> + kfree(cwd);
> + return ret;
> +}
> +
> +struct socket *do_sock_file_restore(struct ckpt_ctx *ctx,
> + struct ckpt_hdr_socket *h)
> +{
> + struct socket *socket;
> + int ret;
> +
> + ret = sock_create(h->sock_common.family, h->sock.type, 0, &socket);
> + if (ret < 0)
> + return ERR_PTR(ret);
> +
> + if (h->sock_common.family == AF_UNIX) {
> + ret = sock_unix_restore(ctx, h, socket);
> + ckpt_debug("sock_unix_restore: %i\n", ret);
> + } else {
> + ckpt_debug("unsupported family %i\n", h->sock_common.family);
> + ret = -EINVAL;
> + }
> +
> + if (ret)
> + goto out;
> +
> + ret = sock_cptrst(ctx, socket->sk, h, CKPT_RST);
> + out:
> + if (ret) {
> + sock_release(socket);
> + socket = ERR_PTR(ret);
> + }
> +
> + return socket;
> +}
> +
> diff --git a/net/socket.c b/net/socket.c
> index 017f6e6..ff556fc 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -96,6 +96,8 @@
> #include <net/sock.h>
> #include <linux/netfilter.h>
>
> +#include <linux/checkpoint.h>
> +
> static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
> static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
> unsigned long nr_segs, loff_t pos);
> @@ -140,6 +142,9 @@ static const struct file_operations socket_file_ops = {
> .sendpage = sock_sendpage,
> .splice_write = generic_splice_sendpage,
> .splice_read = sock_splice_read,
> +#ifdef CONFIG_CHECKPOINT
> + .checkpoint = sock_file_checkpoint,
> +#endif
> };
>
> /*
> @@ -415,6 +420,86 @@ int sock_map_fd(struct socket *sock, int flags)
> return fd;
> }
>
> +#ifdef CONFIG_CHECKPOINT
> +int sock_file_checkpoint(struct ckpt_ctx *ctx, void *ptr)
> +{
> + struct ckpt_hdr_file_socket *h;
> + int ret;
> + struct file *file = ptr;
> +
> + h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_FILE);
> + if (!h)
> + return -ENOMEM;
> +
> + h->common.f_type = CKPT_FILE_SOCKET;
> +
> + ret = checkpoint_file_common(ctx, file, &h->common);
> + if (ret < 0)
> + goto out;
> + ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
> + if (ret < 0)
> + goto out;
> +
> + ret = do_sock_file_checkpoint(ctx, file);
> + out:
> + ckpt_hdr_put(ctx, h);
> + return ret;
> +}
> +
> +static struct file *sock_alloc_attach_fd(struct socket *socket)
Nit: I think this name is misleading - sock_attach_fd() itself is
already and should have been sock_attach_file() IMHO - so perhaps
s/fd/file here ?
> +{
> + struct file *file;
> + int err;
> +
> + file = get_empty_filp();
> + if (!file)
> + return ERR_PTR(ENOMEM);
> +
> + err = sock_attach_fd(socket, file, 0);
> + if (err < 0) {
> + put_filp(file);
> + file = ERR_PTR(err);
> + }
> +
> + return file;
> +}
> +
> +void *sock_file_restore(struct ckpt_ctx *ctx)
> +{
> + struct ckpt_hdr_socket *h = NULL;
> + struct socket *socket = NULL;
> + struct file *file = NULL;
> + int err;
> +
> + h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_SOCKET);
> + if (IS_ERR(h))
> + return h;
> +
> + socket = do_sock_file_restore(ctx, h);
> + if (IS_ERR(socket)) {
> + err = PTR_ERR(socket);
> + goto err_put;
> + }
> +
> + file = sock_alloc_attach_fd(socket);
> + if (IS_ERR(file)) {
> + err = PTR_ERR(file);
> + goto err_release;
> + }
> +
> + ckpt_hdr_put(ctx, h);
> +
> + return file;
> +
> + err_release:
> + sock_release(socket);
> + err_put:
> + ckpt_hdr_put(ctx, h);
> +
> + return ERR_PTR(err);
> +}
> +#endif /* CONFIG_CHECKPOINT */
> +
> static struct socket *sock_from_file(struct file *file, int *err)
> {
> if (file->f_op == &socket_file_ops)
Oren.
^ permalink raw reply
* Re: [PATCH] net: shrink net_device by #ifdef-ing protocol-specific members
From: Joe Perches @ 2009-07-28 16:49 UTC (permalink / raw)
To: Octavian Purdila; +Cc: David Miller, lgrijincu, netdev, eric.dumazet
In-Reply-To: <200907281743.27871.opurdila@ixiacom.com>
On Tue, 2009-07-28 at 17:43 +0300, Octavian Purdila wrote:
> On Monday 27 July 2009 18:26:44 David Miller wrote:
> > From: Lucian Adrian Grijincu <lgrijincu@ixiacom.com>
> > > Some members of net_device are used only by some protocols.
> > > If those protocols are not compiled (as modules or linked in) they
> > > should not take up space in the structure.
> > This benefits, at best, %0.000000001 of users of the Linux kernel,
> > because every distribution is going to turn on every single option.
> Not all Linux users are using regular (desktop/server) distributions. Linux is
> used in embedded systems as well and in these case it makes sense to turn off
> ax25/econet/decnet and in some cases even wireless/ipv6.
> > If you want to shrink structures, find ways to eliminate or
> > shrink structure members in all cases.
> We are looking into that as well since we have a pretty aggressive goal (get
> net_device to 450 bytes or so), but we thought of starting with the low
> hanging fruits.
> Any suggestions in this area?
Some maybe not so good ones:
Perhaps:
struct timer_list watchdog_timer;
might become a
struct timer_list *watchdog_timer;
Maybe all the protocol/mac/bridge/vlan/garp/wireless specific
pointers might become a pointer to a list or array of pointers
allocated on demand.
Maybe combine perm_addr/broadcast/mc_list/uc addresses into a
single list with type information. Maybe include dev_addrs,
but it's iterated with an rcu lock held.
Gaining less than 0, except maybe for weird network testing devices,
use a pointer to struct net_device_stats.
^ permalink raw reply
* [PATCH 0/2] IPVS: make use of pr_fmt and friends
From: Hannes Eder @ 2009-07-28 16:05 UTC (permalink / raw)
To: lvs-devel, netdev; +Cc: linux-kernel, Jan Engelhardt
The following series makes use of pr_fmt and friends instead of printk.
Hannes Eder (2):
IPVS: use pr_err and friends instead of IP_VS_ERR and friends
IPVS: use pr_fmt
include/net/ip_vs.h | 116 +++++++++++++++----------------
net/netfilter/ipvs/ip_vs_app.c | 3 +
net/netfilter/ipvs/ip_vs_conn.c | 15 ++--
net/netfilter/ipvs/ip_vs_core.c | 25 ++++---
net/netfilter/ipvs/ip_vs_ctl.c | 59 ++++++++--------
net/netfilter/ipvs/ip_vs_dh.c | 5 +
net/netfilter/ipvs/ip_vs_est.c | 4 +
net/netfilter/ipvs/ip_vs_ftp.c | 7 +-
net/netfilter/ipvs/ip_vs_lblc.c | 7 +-
net/netfilter/ipvs/ip_vs_lblcr.c | 9 ++
net/netfilter/ipvs/ip_vs_lc.c | 3 +
net/netfilter/ipvs/ip_vs_nq.c | 3 +
net/netfilter/ipvs/ip_vs_proto.c | 9 ++
net/netfilter/ipvs/ip_vs_proto_ah_esp.c | 7 +-
net/netfilter/ipvs/ip_vs_proto_tcp.c | 3 +
net/netfilter/ipvs/ip_vs_proto_udp.c | 3 +
net/netfilter/ipvs/ip_vs_rr.c | 3 +
net/netfilter/ipvs/ip_vs_sched.c | 39 ++++++----
net/netfilter/ipvs/ip_vs_sed.c | 3 +
net/netfilter/ipvs/ip_vs_sh.c | 5 +
net/netfilter/ipvs/ip_vs_sync.c | 49 +++++++------
net/netfilter/ipvs/ip_vs_wlc.c | 3 +
net/netfilter/ipvs/ip_vs_wrr.c | 5 +
net/netfilter/ipvs/ip_vs_xmit.c | 3 +
24 files changed, 227 insertions(+), 161 deletions(-)
^ permalink raw reply
* [PATCH 2/2] IPVS: use pr_err and friends instead of IP_VS_ERR and friends
From: Hannes Eder @ 2009-07-28 16:06 UTC (permalink / raw)
To: lvs-devel, netdev; +Cc: linux-kernel, Jan Engelhardt
In-Reply-To: <20090728160145.12503.61834.stgit@jazzy.zrh.corp.google.com>
Since pr_err and friends is used instead of printk there is not point
in keeping IP_VS_ERR and friends.
Signed-off-by: Hannes Eder <heder@google.com>
include/net/ip_vs.h | 3 --
net/netfilter/ipvs/ip_vs_conn.c | 12 ++++----
net/netfilter/ipvs/ip_vs_core.c | 22 +++++++--------
net/netfilter/ipvs/ip_vs_ctl.c | 56 +++++++++++++++++++-------------------
net/netfilter/ipvs/ip_vs_dh.c | 2 +
net/netfilter/ipvs/ip_vs_ftp.c | 4 +--
net/netfilter/ipvs/ip_vs_lblc.c | 4 +--
net/netfilter/ipvs/ip_vs_lblcr.c | 6 ++--
net/netfilter/ipvs/ip_vs_proto.c | 2 +
net/netfilter/ipvs/ip_vs_sched.c | 36 ++++++++++++------------
net/netfilter/ipvs/ip_vs_sh.c | 2 +
net/netfilter/ipvs/ip_vs_sync.c | 46 ++++++++++++++++---------------
net/netfilter/ipvs/ip_vs_wrr.c | 2 +
13 files changed, 97 insertions(+), 100 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 99f09ab..a6fe3fc 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -150,9 +150,6 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
#endif
#define IP_VS_BUG() BUG()
-#define IP_VS_ERR(msg...) pr_err(msg)
-#define IP_VS_INFO(msg...) pr_info(msg)
-#define IP_VS_WARNING(msg...) pr_warning(msg)
#define IP_VS_ERR_RL(msg...) \
do { \
if (net_ratelimit()) \
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index e613745..6d9b855 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -154,8 +154,8 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
atomic_inc(&cp->refcnt);
ret = 1;
} else {
- IP_VS_ERR("ip_vs_conn_hash(): request for already hashed, "
- "called from %p\n", __builtin_return_address(0));
+ pr_err("ip_vs_conn_hash(): request for already hashed, "
+ "called from %p\n", __builtin_return_address(0));
ret = 0;
}
@@ -1087,10 +1087,10 @@ int __init ip_vs_conn_init(void)
return -ENOMEM;
}
- IP_VS_INFO("Connection hash table configured "
- "(size=%d, memory=%ldKbytes)\n",
- IP_VS_CONN_TAB_SIZE,
- (long)(IP_VS_CONN_TAB_SIZE*sizeof(struct list_head))/1024);
+ pr_info("Connection hash table configured "
+ "(size=%d, memory=%ldKbytes)\n",
+ IP_VS_CONN_TAB_SIZE,
+ (long)(IP_VS_CONN_TAB_SIZE*sizeof(struct list_head))/1024);
IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
sizeof(struct ip_vs_conn));
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 6811dca..ad29e41 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -391,9 +391,9 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
*/
if (!svc->fwmark && pptr[1] != svc->port) {
if (!svc->port)
- IP_VS_ERR("Schedule: port zero only supported "
- "in persistent services, "
- "check your ipvs configuration\n");
+ pr_err("Schedule: port zero only supported "
+ "in persistent services, "
+ "check your ipvs configuration\n");
return NULL;
}
@@ -667,8 +667,8 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
unsigned int verdict = NF_DROP;
if (IP_VS_FWD_METHOD(cp) != 0) {
- IP_VS_ERR("shouldn't reach here, because the box is on the "
- "half connection in the tun/dr module.\n");
+ pr_err("shouldn't reach here, because the box is on the "
+ "half connection in the tun/dr module.\n");
}
/* Ensure the checksum is correct */
@@ -1490,7 +1490,7 @@ static int __init ip_vs_init(void)
ret = ip_vs_control_init();
if (ret < 0) {
- IP_VS_ERR("can't setup control.\n");
+ pr_err("can't setup control.\n");
goto cleanup_estimator;
}
@@ -1498,23 +1498,23 @@ static int __init ip_vs_init(void)
ret = ip_vs_app_init();
if (ret < 0) {
- IP_VS_ERR("can't setup application helper.\n");
+ pr_err("can't setup application helper.\n");
goto cleanup_protocol;
}
ret = ip_vs_conn_init();
if (ret < 0) {
- IP_VS_ERR("can't setup connection table.\n");
+ pr_err("can't setup connection table.\n");
goto cleanup_app;
}
ret = nf_register_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops));
if (ret < 0) {
- IP_VS_ERR("can't register hooks.\n");
+ pr_err("can't register hooks.\n");
goto cleanup_conn;
}
- IP_VS_INFO("ipvs loaded.\n");
+ pr_info("ipvs loaded.\n");
return ret;
cleanup_conn:
@@ -1537,7 +1537,7 @@ static void __exit ip_vs_cleanup(void)
ip_vs_protocol_cleanup();
ip_vs_control_cleanup();
ip_vs_estimator_cleanup();
- IP_VS_INFO("ipvs unloaded.\n");
+ pr_info("ipvs unloaded.\n");
}
module_init(ip_vs_init);
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 83a7ab6..965adc9 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -343,8 +343,8 @@ static int ip_vs_svc_hash(struct ip_vs_service *svc)
unsigned hash;
if (svc->flags & IP_VS_SVC_F_HASHED) {
- IP_VS_ERR("ip_vs_svc_hash(): request for already hashed, "
- "called from %p\n", __builtin_return_address(0));
+ pr_err("ip_vs_svc_hash(): request for already hashed, "
+ "called from %p\n", __builtin_return_address(0));
return 0;
}
@@ -377,8 +377,8 @@ static int ip_vs_svc_hash(struct ip_vs_service *svc)
static int ip_vs_svc_unhash(struct ip_vs_service *svc)
{
if (!(svc->flags & IP_VS_SVC_F_HASHED)) {
- IP_VS_ERR("ip_vs_svc_unhash(): request for unhash flagged, "
- "called from %p\n", __builtin_return_address(0));
+ pr_err("ip_vs_svc_unhash(): request for unhash flagged, "
+ "called from %p\n", __builtin_return_address(0));
return 0;
}
@@ -844,7 +844,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
dest = kzalloc(sizeof(struct ip_vs_dest), GFP_ATOMIC);
if (dest == NULL) {
- IP_VS_ERR("ip_vs_new_dest: kmalloc failed.\n");
+ pr_err("ip_vs_new_dest: kmalloc failed.\n");
return -ENOMEM;
}
@@ -888,13 +888,13 @@ ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
EnterFunction(2);
if (udest->weight < 0) {
- IP_VS_ERR("ip_vs_add_dest(): server weight less than zero\n");
+ pr_err("ip_vs_add_dest(): server weight less than zero\n");
return -ERANGE;
}
if (udest->l_threshold > udest->u_threshold) {
- IP_VS_ERR("ip_vs_add_dest(): lower threshold is higher than "
- "upper threshold\n");
+ pr_err("ip_vs_add_dest(): lower threshold is higher than "
+ "upper threshold\n");
return -ERANGE;
}
@@ -1000,13 +1000,13 @@ ip_vs_edit_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
EnterFunction(2);
if (udest->weight < 0) {
- IP_VS_ERR("ip_vs_edit_dest(): server weight less than zero\n");
+ pr_err("ip_vs_edit_dest(): server weight less than zero\n");
return -ERANGE;
}
if (udest->l_threshold > udest->u_threshold) {
- IP_VS_ERR("ip_vs_edit_dest(): lower threshold is higher than "
- "upper threshold\n");
+ pr_err("ip_vs_edit_dest(): lower threshold is higher than "
+ "upper threshold\n");
return -ERANGE;
}
@@ -1164,8 +1164,8 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u,
/* Lookup the scheduler by 'u->sched_name' */
sched = ip_vs_scheduler_get(u->sched_name);
if (sched == NULL) {
- IP_VS_INFO("Scheduler module ip_vs_%s not found\n",
- u->sched_name);
+ pr_info("Scheduler module ip_vs_%s not found\n",
+ u->sched_name);
ret = -ENOENT;
goto out_mod_dec;
}
@@ -1262,8 +1262,8 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u)
*/
sched = ip_vs_scheduler_get(u->sched_name);
if (sched == NULL) {
- IP_VS_INFO("Scheduler module ip_vs_%s not found\n",
- u->sched_name);
+ pr_info("Scheduler module ip_vs_%s not found\n",
+ u->sched_name);
return -ENOENT;
}
old_sched = sched;
@@ -2094,8 +2094,8 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
return -EPERM;
if (len != set_arglen[SET_CMDID(cmd)]) {
- IP_VS_ERR("set_ctl: len %u != %u\n",
- len, set_arglen[SET_CMDID(cmd)]);
+ pr_err("set_ctl: len %u != %u\n",
+ len, set_arglen[SET_CMDID(cmd)]);
return -EINVAL;
}
@@ -2146,9 +2146,9 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
/* Check for valid protocol: TCP or UDP, even for fwmark!=0 */
if (usvc.protocol != IPPROTO_TCP && usvc.protocol != IPPROTO_UDP) {
- IP_VS_ERR("set_ctl: invalid protocol: %d %pI4:%d %s\n",
- usvc.protocol, &usvc.addr.ip,
- ntohs(usvc.port), usvc.sched_name);
+ pr_err("set_ctl: invalid protocol: %d %pI4:%d %s\n",
+ usvc.protocol, &usvc.addr.ip,
+ ntohs(usvc.port), usvc.sched_name);
ret = -EFAULT;
goto out_unlock;
}
@@ -2373,8 +2373,8 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
return -EPERM;
if (*len < get_arglen[GET_CMDID(cmd)]) {
- IP_VS_ERR("get_ctl: len %u < %u\n",
- *len, get_arglen[GET_CMDID(cmd)]);
+ pr_err("get_ctl: len %u < %u\n",
+ *len, get_arglen[GET_CMDID(cmd)]);
return -EINVAL;
}
@@ -2419,7 +2419,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
size = sizeof(*get) +
sizeof(struct ip_vs_service_entry) * get->num_services;
if (*len != size) {
- IP_VS_ERR("length: %u != %u\n", *len, size);
+ pr_err("length: %u != %u\n", *len, size);
ret = -EINVAL;
goto out;
}
@@ -2459,7 +2459,7 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
size = sizeof(*get) +
sizeof(struct ip_vs_dest_entry) * get->num_dests;
if (*len != size) {
- IP_VS_ERR("length: %u != %u\n", *len, size);
+ pr_err("length: %u != %u\n", *len, size);
ret = -EINVAL;
goto out;
}
@@ -3187,7 +3187,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
else if (cmd == IPVS_CMD_GET_CONFIG)
reply_cmd = IPVS_CMD_SET_CONFIG;
else {
- IP_VS_ERR("unknown Generic Netlink command\n");
+ pr_err("unknown Generic Netlink command\n");
return -EINVAL;
}
@@ -3252,7 +3252,7 @@ static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
goto out;
nla_put_failure:
- IP_VS_ERR("not enough space in Netlink message\n");
+ pr_err("not enough space in Netlink message\n");
ret = -EMSGSIZE;
out_err:
@@ -3397,13 +3397,13 @@ int __init ip_vs_control_init(void)
ret = nf_register_sockopt(&ip_vs_sockopts);
if (ret) {
- IP_VS_ERR("cannot register sockopt.\n");
+ pr_err("cannot register sockopt.\n");
return ret;
}
ret = ip_vs_genl_register();
if (ret) {
- IP_VS_ERR("cannot register Generic Netlink interface.\n");
+ pr_err("cannot register Generic Netlink interface.\n");
nf_unregister_sockopt(&ip_vs_sockopts);
return ret;
}
diff --git a/net/netfilter/ipvs/ip_vs_dh.c b/net/netfilter/ipvs/ip_vs_dh.c
index d0c0594..3510b8a 100644
--- a/net/netfilter/ipvs/ip_vs_dh.c
+++ b/net/netfilter/ipvs/ip_vs_dh.c
@@ -150,7 +150,7 @@ static int ip_vs_dh_init_svc(struct ip_vs_service *svc)
tbl = kmalloc(sizeof(struct ip_vs_dh_bucket)*IP_VS_DH_TAB_SIZE,
GFP_ATOMIC);
if (tbl == NULL) {
- IP_VS_ERR("ip_vs_dh_init_svc(): no memory\n");
+ pr_err("ip_vs_dh_init_svc(): no memory\n");
return -ENOMEM;
}
svc->sched_data = tbl;
diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 9c16a3f..33e2c79 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -385,8 +385,8 @@ static int __init ip_vs_ftp_init(void)
ret = register_ip_vs_app_inc(app, app->protocol, ports[i]);
if (ret)
break;
- IP_VS_INFO("%s: loaded support on port[%d] = %d\n",
- app->name, i, ports[i]);
+ pr_info("%s: loaded support on port[%d] = %d\n",
+ app->name, i, ports[i]);
}
if (ret)
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 66f625b..930eda7 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -205,7 +205,7 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,
if (!en) {
en = kmalloc(sizeof(*en), GFP_ATOMIC);
if (!en) {
- IP_VS_ERR("ip_vs_lblc_new(): no memory\n");
+ pr_err("ip_vs_lblc_new(): no memory\n");
return NULL;
}
@@ -338,7 +338,7 @@ static int ip_vs_lblc_init_svc(struct ip_vs_service *svc)
*/
tbl = kmalloc(sizeof(*tbl), GFP_ATOMIC);
if (tbl == NULL) {
- IP_VS_ERR("ip_vs_lblc_init_svc(): no memory\n");
+ pr_err("ip_vs_lblc_init_svc(): no memory\n");
return -ENOMEM;
}
svc->sched_data = tbl;
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 63cca2b..4b3e7f6 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -111,7 +111,7 @@ ip_vs_dest_set_insert(struct ip_vs_dest_set *set, struct ip_vs_dest *dest)
e = kmalloc(sizeof(*e), GFP_ATOMIC);
if (e == NULL) {
- IP_VS_ERR("ip_vs_dest_set_insert(): no memory\n");
+ pr_err("ip_vs_dest_set_insert(): no memory\n");
return NULL;
}
@@ -380,7 +380,7 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr,
if (!en) {
en = kmalloc(sizeof(*en), GFP_ATOMIC);
if (!en) {
- IP_VS_ERR("ip_vs_lblcr_new(): no memory\n");
+ pr_err("ip_vs_lblcr_new(): no memory\n");
return NULL;
}
@@ -514,7 +514,7 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
*/
tbl = kmalloc(sizeof(*tbl), GFP_ATOMIC);
if (tbl == NULL) {
- IP_VS_ERR("ip_vs_lblcr_init_svc(): no memory\n");
+ pr_err("ip_vs_lblcr_init_svc(): no memory\n");
return -ENOMEM;
}
svc->sched_data = tbl;
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c
index a95bc40..85c8892 100644
--- a/net/netfilter/ipvs/ip_vs_proto.c
+++ b/net/netfilter/ipvs/ip_vs_proto.c
@@ -262,7 +262,7 @@ int __init ip_vs_protocol_init(void)
#ifdef CONFIG_IP_VS_PROTO_ESP
REGISTER_PROTOCOL(&ip_vs_protocol_esp);
#endif
- IP_VS_INFO("Registered protocols (%s)\n", &protocols[2]);
+ pr_info("Registered protocols (%s)\n", &protocols[2]);
return 0;
}
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 87bc5ea..727e412 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -47,11 +47,11 @@ int ip_vs_bind_scheduler(struct ip_vs_service *svc,
int ret;
if (svc == NULL) {
- IP_VS_ERR("ip_vs_bind_scheduler(): svc arg NULL\n");
+ pr_err("ip_vs_bind_scheduler(): svc arg NULL\n");
return -EINVAL;
}
if (scheduler == NULL) {
- IP_VS_ERR("ip_vs_bind_scheduler(): scheduler arg NULL\n");
+ pr_err("ip_vs_bind_scheduler(): scheduler arg NULL\n");
return -EINVAL;
}
@@ -60,7 +60,7 @@ int ip_vs_bind_scheduler(struct ip_vs_service *svc,
if (scheduler->init_service) {
ret = scheduler->init_service(svc);
if (ret) {
- IP_VS_ERR("ip_vs_bind_scheduler(): init error\n");
+ pr_err("ip_vs_bind_scheduler(): init error\n");
return ret;
}
}
@@ -77,19 +77,19 @@ int ip_vs_unbind_scheduler(struct ip_vs_service *svc)
struct ip_vs_scheduler *sched;
if (svc == NULL) {
- IP_VS_ERR("ip_vs_unbind_scheduler(): svc arg NULL\n");
+ pr_err("ip_vs_unbind_scheduler(): svc arg NULL\n");
return -EINVAL;
}
sched = svc->scheduler;
if (sched == NULL) {
- IP_VS_ERR("ip_vs_unbind_scheduler(): svc isn't bound\n");
+ pr_err("ip_vs_unbind_scheduler(): svc isn't bound\n");
return -EINVAL;
}
if (sched->done_service) {
if (sched->done_service(svc) != 0) {
- IP_VS_ERR("ip_vs_unbind_scheduler(): done error\n");
+ pr_err("ip_vs_unbind_scheduler(): done error\n");
return -EINVAL;
}
}
@@ -173,12 +173,12 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
struct ip_vs_scheduler *sched;
if (!scheduler) {
- IP_VS_ERR("register_ip_vs_scheduler(): NULL arg\n");
+ pr_err("register_ip_vs_scheduler(): NULL arg\n");
return -EINVAL;
}
if (!scheduler->name) {
- IP_VS_ERR("register_ip_vs_scheduler(): NULL scheduler_name\n");
+ pr_err("register_ip_vs_scheduler(): NULL scheduler_name\n");
return -EINVAL;
}
@@ -190,8 +190,8 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
if (!list_empty(&scheduler->n_list)) {
write_unlock_bh(&__ip_vs_sched_lock);
ip_vs_use_count_dec();
- IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler "
- "already linked\n", scheduler->name);
+ pr_err("register_ip_vs_scheduler(): [%s] scheduler "
+ "already linked\n", scheduler->name);
return -EINVAL;
}
@@ -203,9 +203,9 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
if (strcmp(scheduler->name, sched->name) == 0) {
write_unlock_bh(&__ip_vs_sched_lock);
ip_vs_use_count_dec();
- IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler "
- "already existed in the system\n",
- scheduler->name);
+ pr_err("register_ip_vs_scheduler(): [%s] scheduler "
+ "already existed in the system\n",
+ scheduler->name);
return -EINVAL;
}
}
@@ -215,7 +215,7 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
list_add(&scheduler->n_list, &ip_vs_schedulers);
write_unlock_bh(&__ip_vs_sched_lock);
- IP_VS_INFO("[%s] scheduler registered.\n", scheduler->name);
+ pr_info("[%s] scheduler registered.\n", scheduler->name);
return 0;
}
@@ -227,15 +227,15 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
int unregister_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
{
if (!scheduler) {
- IP_VS_ERR( "unregister_ip_vs_scheduler(): NULL arg\n");
+ pr_err("unregister_ip_vs_scheduler(): NULL arg\n");
return -EINVAL;
}
write_lock_bh(&__ip_vs_sched_lock);
if (list_empty(&scheduler->n_list)) {
write_unlock_bh(&__ip_vs_sched_lock);
- IP_VS_ERR("unregister_ip_vs_scheduler(): [%s] scheduler "
- "is not in the list. failed\n", scheduler->name);
+ pr_err("unregister_ip_vs_scheduler(): [%s] scheduler "
+ "is not in the list. failed\n", scheduler->name);
return -EINVAL;
}
@@ -248,7 +248,7 @@ int unregister_ip_vs_scheduler(struct ip_vs_scheduler *scheduler)
/* decrease the module use count */
ip_vs_use_count_dec();
- IP_VS_INFO("[%s] scheduler unregistered.\n", scheduler->name);
+ pr_info("[%s] scheduler unregistered.\n", scheduler->name);
return 0;
}
diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
index fb4d2d2..f7c7ffa 100644
--- a/net/netfilter/ipvs/ip_vs_sh.c
+++ b/net/netfilter/ipvs/ip_vs_sh.c
@@ -147,7 +147,7 @@ static int ip_vs_sh_init_svc(struct ip_vs_service *svc)
tbl = kmalloc(sizeof(struct ip_vs_sh_bucket)*IP_VS_SH_TAB_SIZE,
GFP_ATOMIC);
if (tbl == NULL) {
- IP_VS_ERR("ip_vs_sh_init_svc(): no memory\n");
+ pr_err("ip_vs_sh_init_svc(): no memory\n");
return -ENOMEM;
}
svc->sched_data = tbl;
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index cc04c99..018af17 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -246,7 +246,7 @@ void ip_vs_sync_conn(struct ip_vs_conn *cp)
if (!curr_sb) {
if (!(curr_sb=ip_vs_sync_buff_create())) {
spin_unlock(&curr_sb_lock);
- IP_VS_ERR("ip_vs_sync_buff_create failed.\n");
+ pr_err("ip_vs_sync_buff_create failed.\n");
return;
}
}
@@ -412,7 +412,7 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
if (dest)
atomic_dec(&dest->refcnt);
if (!cp) {
- IP_VS_ERR("ip_vs_conn_new failed\n");
+ pr_err("ip_vs_conn_new failed\n");
return;
}
} else if (!cp->dest) {
@@ -580,8 +580,8 @@ static int bind_mcastif_addr(struct socket *sock, char *ifname)
addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
if (!addr)
- IP_VS_ERR("You probably need to specify IP address on "
- "multicast interface.\n");
+ pr_err("You probably need to specify IP address on "
+ "multicast interface.\n");
IP_VS_DBG(7, "binding socket with (%s) %pI4\n",
ifname, &addr);
@@ -605,13 +605,13 @@ static struct socket * make_send_sock(void)
/* First create a socket */
result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
if (result < 0) {
- IP_VS_ERR("Error during creation of socket; terminating\n");
+ pr_err("Error during creation of socket; terminating\n");
return ERR_PTR(result);
}
result = set_mcast_if(sock->sk, ip_vs_master_mcast_ifn);
if (result < 0) {
- IP_VS_ERR("Error setting outbound mcast interface\n");
+ pr_err("Error setting outbound mcast interface\n");
goto error;
}
@@ -620,14 +620,14 @@ static struct socket * make_send_sock(void)
result = bind_mcastif_addr(sock, ip_vs_master_mcast_ifn);
if (result < 0) {
- IP_VS_ERR("Error binding address of the mcast interface\n");
+ pr_err("Error binding address of the mcast interface\n");
goto error;
}
result = sock->ops->connect(sock, (struct sockaddr *) &mcast_addr,
sizeof(struct sockaddr), 0);
if (result < 0) {
- IP_VS_ERR("Error connecting to the multicast addr\n");
+ pr_err("Error connecting to the multicast addr\n");
goto error;
}
@@ -650,7 +650,7 @@ static struct socket * make_receive_sock(void)
/* First create a socket */
result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
if (result < 0) {
- IP_VS_ERR("Error during creation of socket; terminating\n");
+ pr_err("Error during creation of socket; terminating\n");
return ERR_PTR(result);
}
@@ -660,7 +660,7 @@ static struct socket * make_receive_sock(void)
result = sock->ops->bind(sock, (struct sockaddr *) &mcast_addr,
sizeof(struct sockaddr));
if (result < 0) {
- IP_VS_ERR("Error binding to the multicast addr\n");
+ pr_err("Error binding to the multicast addr\n");
goto error;
}
@@ -669,7 +669,7 @@ static struct socket * make_receive_sock(void)
(struct in_addr *) &mcast_addr.sin_addr,
ip_vs_backup_mcast_ifn);
if (result < 0) {
- IP_VS_ERR("Error joining to the multicast group\n");
+ pr_err("Error joining to the multicast group\n");
goto error;
}
@@ -709,7 +709,7 @@ ip_vs_send_sync_msg(struct socket *sock, struct ip_vs_sync_mesg *msg)
msg->size = htons(msg->size);
if (ip_vs_send_async(sock, (char *)msg, msize) != msize)
- IP_VS_ERR("ip_vs_send_async error\n");
+ pr_err("ip_vs_send_async error\n");
}
static int
@@ -740,9 +740,9 @@ static int sync_thread_master(void *data)
struct ip_vs_sync_thread_data *tinfo = data;
struct ip_vs_sync_buff *sb;
- IP_VS_INFO("sync thread started: state = MASTER, mcast_ifn = %s, "
- "syncid = %d\n",
- ip_vs_master_mcast_ifn, ip_vs_master_syncid);
+ pr_info("sync thread started: state = MASTER, mcast_ifn = %s, "
+ "syncid = %d\n",
+ ip_vs_master_mcast_ifn, ip_vs_master_syncid);
while (!kthread_should_stop()) {
while ((sb = sb_dequeue())) {
@@ -783,9 +783,9 @@ static int sync_thread_backup(void *data)
struct ip_vs_sync_thread_data *tinfo = data;
int len;
- IP_VS_INFO("sync thread started: state = BACKUP, mcast_ifn = %s, "
- "syncid = %d\n",
- ip_vs_backup_mcast_ifn, ip_vs_backup_syncid);
+ pr_info("sync thread started: state = BACKUP, mcast_ifn = %s, "
+ "syncid = %d\n",
+ ip_vs_backup_mcast_ifn, ip_vs_backup_syncid);
while (!kthread_should_stop()) {
wait_event_interruptible(*tinfo->sock->sk->sk_sleep,
@@ -797,7 +797,7 @@ static int sync_thread_backup(void *data)
len = ip_vs_receive(tinfo->sock, tinfo->buf,
sync_recv_mesg_maxlen);
if (len <= 0) {
- IP_VS_ERR("receiving message error\n");
+ pr_err("receiving message error\n");
break;
}
@@ -910,8 +910,8 @@ int stop_sync_thread(int state)
if (!sync_master_thread)
return -ESRCH;
- IP_VS_INFO("stopping master sync thread %d ...\n",
- task_pid_nr(sync_master_thread));
+ pr_info("stopping master sync thread %d ...\n",
+ task_pid_nr(sync_master_thread));
/*
* The lock synchronizes with sb_queue_tail(), so that we don't
@@ -928,8 +928,8 @@ int stop_sync_thread(int state)
if (!sync_backup_thread)
return -ESRCH;
- IP_VS_INFO("stopping backup sync thread %d ...\n",
- task_pid_nr(sync_backup_thread));
+ pr_info("stopping backup sync thread %d ...\n",
+ task_pid_nr(sync_backup_thread));
ip_vs_sync_state &= ~IP_VS_STATE_BACKUP;
kthread_stop(sync_backup_thread);
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c
index c39ebb6..86772f2 100644
--- a/net/netfilter/ipvs/ip_vs_wrr.c
+++ b/net/netfilter/ipvs/ip_vs_wrr.c
@@ -97,7 +97,7 @@ static int ip_vs_wrr_init_svc(struct ip_vs_service *svc)
*/
mark = kmalloc(sizeof(struct ip_vs_wrr_mark), GFP_ATOMIC);
if (mark == NULL) {
- IP_VS_ERR("ip_vs_wrr_init_svc(): no memory\n");
+ pr_err("ip_vs_wrr_init_svc(): no memory\n");
return -ENOMEM;
}
mark->cl = &svc->destinations;
^ permalink raw reply related
* [PATCH 1/2] IPVS: use pr_fmt
From: Hannes Eder @ 2009-07-28 16:06 UTC (permalink / raw)
To: lvs-devel, netdev; +Cc: linux-kernel, Jan Engelhardt
In-Reply-To: <20090728160145.12503.61834.stgit@jazzy.zrh.corp.google.com>
While being at it cleanup whitespace.
Signed-off-by: Hannes Eder <heder@google.com>
include/net/ip_vs.h | 119 +++++++++++++++----------------
net/netfilter/ipvs/ip_vs_app.c | 3 +
net/netfilter/ipvs/ip_vs_conn.c | 3 +
net/netfilter/ipvs/ip_vs_core.c | 3 +
net/netfilter/ipvs/ip_vs_ctl.c | 3 +
net/netfilter/ipvs/ip_vs_dh.c | 3 +
net/netfilter/ipvs/ip_vs_est.c | 4 +
net/netfilter/ipvs/ip_vs_ftp.c | 3 +
net/netfilter/ipvs/ip_vs_lblc.c | 3 +
net/netfilter/ipvs/ip_vs_lblcr.c | 3 +
net/netfilter/ipvs/ip_vs_lc.c | 3 +
net/netfilter/ipvs/ip_vs_nq.c | 3 +
net/netfilter/ipvs/ip_vs_proto.c | 7 +-
net/netfilter/ipvs/ip_vs_proto_ah_esp.c | 7 +-
net/netfilter/ipvs/ip_vs_proto_tcp.c | 3 +
net/netfilter/ipvs/ip_vs_proto_udp.c | 3 +
net/netfilter/ipvs/ip_vs_rr.c | 3 +
net/netfilter/ipvs/ip_vs_sched.c | 3 +
net/netfilter/ipvs/ip_vs_sed.c | 3 +
net/netfilter/ipvs/ip_vs_sh.c | 3 +
net/netfilter/ipvs/ip_vs_sync.c | 3 +
net/netfilter/ipvs/ip_vs_wlc.c | 3 +
net/netfilter/ipvs/ip_vs_wrr.c | 3 +
net/netfilter/ipvs/ip_vs_xmit.c | 3 +
24 files changed, 133 insertions(+), 64 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index e01cc2d..99f09ab 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -99,47 +99,47 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
return &buf[*idx - len];
}
-#define IP_VS_DBG_BUF(level, msg...) \
- do { \
- char ip_vs_dbg_buf[160]; \
- int ip_vs_dbg_idx = 0; \
- if (level <= ip_vs_get_debug_level()) \
- printk(KERN_DEBUG "IPVS: " msg); \
- } while (0)
-#define IP_VS_ERR_BUF(msg...) \
- do { \
- char ip_vs_dbg_buf[160]; \
- int ip_vs_dbg_idx = 0; \
- printk(KERN_ERR "IPVS: " msg); \
- } while (0)
+#define IP_VS_DBG_BUF(level, msg...) \
+ do { \
+ char ip_vs_dbg_buf[160]; \
+ int ip_vs_dbg_idx = 0; \
+ if (level <= ip_vs_get_debug_level()) \
+ pr_debug(msg); \
+ } while (0)
+#define IP_VS_ERR_BUF(msg...) \
+ do { \
+ char ip_vs_dbg_buf[160]; \
+ int ip_vs_dbg_idx = 0; \
+ pr_err(msg); \
+ } while (0)
/* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */
-#define IP_VS_DBG_ADDR(af, addr) \
- ip_vs_dbg_addr(af, ip_vs_dbg_buf, \
- sizeof(ip_vs_dbg_buf), addr, \
- &ip_vs_dbg_idx)
-
-#define IP_VS_DBG(level, msg...) \
- do { \
- if (level <= ip_vs_get_debug_level()) \
- printk(KERN_DEBUG "IPVS: " msg); \
- } while (0)
-#define IP_VS_DBG_RL(msg...) \
- do { \
- if (net_ratelimit()) \
- printk(KERN_DEBUG "IPVS: " msg); \
- } while (0)
-#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) \
- do { \
- if (level <= ip_vs_get_debug_level()) \
- pp->debug_packet(pp, skb, ofs, msg); \
- } while (0)
-#define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) \
- do { \
- if (level <= ip_vs_get_debug_level() && \
- net_ratelimit()) \
- pp->debug_packet(pp, skb, ofs, msg); \
- } while (0)
+#define IP_VS_DBG_ADDR(af, addr) \
+ ip_vs_dbg_addr(af, ip_vs_dbg_buf, \
+ sizeof(ip_vs_dbg_buf), addr, \
+ &ip_vs_dbg_idx)
+
+#define IP_VS_DBG(level, msg...) \
+ do { \
+ if (level <= ip_vs_get_debug_level()) \
+ pr_debug(msg); \
+ } while (0)
+#define IP_VS_DBG_RL(msg...) \
+ do { \
+ if (net_ratelimit()) \
+ pr_debug(msg); \
+ } while (0)
+#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) \
+ do { \
+ if (level <= ip_vs_get_debug_level()) \
+ pp->debug_packet(pp, skb, ofs, msg); \
+ } while (0)
+#define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) \
+ do { \
+ if (level <= ip_vs_get_debug_level() && \
+ net_ratelimit()) \
+ pp->debug_packet(pp, skb, ofs, msg); \
+ } while (0)
#else /* NO DEBUGGING at ALL */
#define IP_VS_DBG_BUF(level, msg...) do {} while (0)
#define IP_VS_ERR_BUF(msg...) do {} while (0)
@@ -150,29 +150,28 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
#endif
#define IP_VS_BUG() BUG()
-#define IP_VS_ERR(msg...) printk(KERN_ERR "IPVS: " msg)
-#define IP_VS_INFO(msg...) printk(KERN_INFO "IPVS: " msg)
-#define IP_VS_WARNING(msg...) \
- printk(KERN_WARNING "IPVS: " msg)
-#define IP_VS_ERR_RL(msg...) \
- do { \
- if (net_ratelimit()) \
- printk(KERN_ERR "IPVS: " msg); \
- } while (0)
+#define IP_VS_ERR(msg...) pr_err(msg)
+#define IP_VS_INFO(msg...) pr_info(msg)
+#define IP_VS_WARNING(msg...) pr_warning(msg)
+#define IP_VS_ERR_RL(msg...) \
+ do { \
+ if (net_ratelimit()) \
+ pr_err(msg); \
+ } while (0)
#ifdef CONFIG_IP_VS_DEBUG
-#define EnterFunction(level) \
- do { \
- if (level <= ip_vs_get_debug_level()) \
- printk(KERN_DEBUG "Enter: %s, %s line %i\n", \
- __func__, __FILE__, __LINE__); \
- } while (0)
-#define LeaveFunction(level) \
- do { \
- if (level <= ip_vs_get_debug_level()) \
- printk(KERN_DEBUG "Leave: %s, %s line %i\n", \
- __func__, __FILE__, __LINE__); \
- } while (0)
+#define EnterFunction(level) \
+ do { \
+ if (level <= ip_vs_get_debug_level()) \
+ pr_debug("Enter: %s, %s line %i\n", \
+ __func__, __FILE__, __LINE__); \
+ } while (0)
+#define LeaveFunction(level) \
+ do { \
+ if (level <= ip_vs_get_debug_level()) \
+ pr_debug("Leave: %s, %s line %i\n", \
+ __func__, __FILE__, __LINE__); \
+ } while (0)
#else
#define EnterFunction(level) do {} while (0)
#define LeaveFunction(level) do {} while (0)
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c
index 201b8ea..c1781f8 100644
--- a/net/netfilter/ipvs/ip_vs_app.c
+++ b/net/netfilter/ipvs/ip_vs_app.c
@@ -18,6 +18,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 928af1c..e613745 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -22,6 +22,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/net.h>
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 8dddb17..6811dca 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -24,6 +24,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ip.h>
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index beaf129..83a7ab6 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -18,6 +18,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
diff --git a/net/netfilter/ipvs/ip_vs_dh.c b/net/netfilter/ipvs/ip_vs_dh.c
index a9dac74..d0c0594 100644
--- a/net/netfilter/ipvs/ip_vs_dh.c
+++ b/net/netfilter/ipvs/ip_vs_dh.c
@@ -35,6 +35,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/ip.h>
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c
index 2eb2860..702b53c 100644
--- a/net/netfilter/ipvs/ip_vs_est.c
+++ b/net/netfilter/ipvs/ip_vs_est.c
@@ -11,6 +11,10 @@
* Changes:
*
*/
+
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/slab.h>
diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 428edbf..9c16a3f 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -22,6 +22,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 537a7a1..66f625b 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -39,6 +39,9 @@
* me to write this module.
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/ip.h>
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index c8f8687..63cca2b 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -37,6 +37,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/ip.h>
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_lc.c b/net/netfilter/ipvs/ip_vs_lc.c
index d0dadc8..4ecd5e1 100644
--- a/net/netfilter/ipvs/ip_vs_lc.c
+++ b/net/netfilter/ipvs/ip_vs_lc.c
@@ -14,6 +14,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_nq.c b/net/netfilter/ipvs/ip_vs_nq.c
index 694952d..2224478 100644
--- a/net/netfilter/ipvs/ip_vs_nq.c
+++ b/net/netfilter/ipvs/ip_vs_nq.c
@@ -31,6 +31,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c
index a01520e..a95bc40 100644
--- a/net/netfilter/ipvs/ip_vs_proto.c
+++ b/net/netfilter/ipvs/ip_vs_proto.c
@@ -13,6 +13,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
@@ -181,7 +184,7 @@ ip_vs_tcpudp_debug_packet_v4(struct ip_vs_protocol *pp,
&ih->daddr, ntohs(pptr[1]));
}
- printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
+ pr_debug("%s: %s\n", msg, buf);
}
#ifdef CONFIG_IP_VS_IPV6
@@ -215,7 +218,7 @@ ip_vs_tcpudp_debug_packet_v6(struct ip_vs_protocol *pp,
&ih->daddr, ntohs(pptr[1]));
}
- printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
+ pr_debug("%s: %s\n", msg, buf);
}
#endif
diff --git a/net/netfilter/ipvs/ip_vs_proto_ah_esp.c b/net/netfilter/ipvs/ip_vs_proto_ah_esp.c
index 79f56c1..c30b43c 100644
--- a/net/netfilter/ipvs/ip_vs_proto_ah_esp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_ah_esp.c
@@ -10,6 +10,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/module.h>
@@ -138,7 +141,7 @@ ah_esp_debug_packet_v4(struct ip_vs_protocol *pp, const struct sk_buff *skb,
sprintf(buf, "%s %pI4->%pI4",
pp->name, &ih->saddr, &ih->daddr);
- printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
+ pr_debug("%s: %s\n", msg, buf);
}
#ifdef CONFIG_IP_VS_IPV6
@@ -156,7 +159,7 @@ ah_esp_debug_packet_v6(struct ip_vs_protocol *pp, const struct sk_buff *skb,
sprintf(buf, "%s %pI6->%pI6",
pp->name, &ih->saddr, &ih->daddr);
- printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
+ pr_debug("%s: %s\n", msg, buf);
}
#endif
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index 8cba418..c36c80d 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -13,6 +13,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/kernel.h>
#include <linux/ip.h>
#include <linux/tcp.h> /* for tcphdr */
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
index d2930a7..96ebe40 100644
--- a/net/netfilter/ipvs/ip_vs_proto_udp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_udp.c
@@ -13,6 +13,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_rr.c b/net/netfilter/ipvs/ip_vs_rr.c
index 2d16ab7..b01007e 100644
--- a/net/netfilter/ipvs/ip_vs_rr.c
+++ b/net/netfilter/ipvs/ip_vs_rr.c
@@ -19,6 +19,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index a46ad9e..87bc5ea 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -17,6 +17,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
diff --git a/net/netfilter/ipvs/ip_vs_sed.c b/net/netfilter/ipvs/ip_vs_sed.c
index 20e4657..4f745dd 100644
--- a/net/netfilter/ipvs/ip_vs_sed.c
+++ b/net/netfilter/ipvs/ip_vs_sed.c
@@ -35,6 +35,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_sh.c b/net/netfilter/ipvs/ip_vs_sh.c
index 75709eb..fb4d2d2 100644
--- a/net/netfilter/ipvs/ip_vs_sh.c
+++ b/net/netfilter/ipvs/ip_vs_sh.c
@@ -32,6 +32,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/ip.h>
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 5c48378..cc04c99 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -17,6 +17,9 @@
* Justin Ossevoort : Fix endian problem on sync message size.
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/inetdevice.h>
diff --git a/net/netfilter/ipvs/ip_vs_wlc.c b/net/netfilter/ipvs/ip_vs_wlc.c
index 8e94256..bbddfdb 100644
--- a/net/netfilter/ipvs/ip_vs_wlc.c
+++ b/net/netfilter/ipvs/ip_vs_wlc.c
@@ -19,6 +19,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c
index f7d74ef..c39ebb6 100644
--- a/net/netfilter/ipvs/ip_vs_wrr.c
+++ b/net/netfilter/ipvs/ip_vs_wrr.c
@@ -18,6 +18,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/net.h>
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 425ab14..e5e0025 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -13,6 +13,9 @@
*
*/
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
#include <linux/kernel.h>
#include <linux/tcp.h> /* for tcphdr */
#include <net/ip.h>
^ permalink raw reply related
* Re: [PATCH 2/2] c/r: Add AF_INET support (v3)
From: Dan Smith @ 2009-07-28 16:00 UTC (permalink / raw)
To: John Dykstra; +Cc: containers, netdev, Oren Laaden, Alexey Dobriyan
In-Reply-To: <1248555754.16746.55.camel@merlyn>
JD> I don't know whether this would affect palatibility (sic) for the
JD> mainline, but it bothers me... socket.h (and sock.h) are included
JD> all over the place in the kernel, and this definition is only
JD> needed in very limited locations. Can it be placed in a .h used
JD> only by checkpoint code?
This was moved here based on previous comments on the patch.
Personally, I think socket.h is a little too wide. While iterating on
this patch locally, I've discovered that socket.h won't really work
because in6.h includes it early and thus I'm unable to include some of
the address structures as a result. I think going back to a
checkpoint-specific header would be helpful.
JD> There's an interesting design choice re TIME_WAIT and similar
JD> states. In a migration scenario, do those sks migrate? If the
JD> tree isn't going to be restored for a while., you want the
JD> original host to continue to respond to those four-tuples If the
JD> IP address of the original is immediately migrated to another
JD> machine, you want the TIME_WAIT sks to migrate too.
Well, as far as I'm concerned, the only sane migration scenario is one
where you migrate the IP address and virtual interface with the
task. When you destroy the virtual interface after (or during) the
migration, the TIME_WAIT socket will disappear from the sending host.
I think that we need to increment timers like this on restore anyway,
which should make sure that the TIME_WAIT timers run for the same
amount of wall-clock time regardless of how much time was spent in the
process of migration, right?
Since checkpoint is not aware of a potential migration, a regular
(i.e. not intended for migration) checkpoint operation on a task
running in the init netns will leave the TIME_WAIT socket in place
until the timer expires.
>> +static int sock_inet_restart(struct ckpt_ctx *ctx,
>> + struct ckpt_hdr_socket *h,
>> + struct socket *socket)
>> +{
>> + int ret;
>> + struct ckpt_hdr_socket_inet *in;
>> + struct sockaddr_in *l = (struct sockaddr_in *)&h->laddr;
>> +
>> + in = ckpt_read_obj_type(ctx, sizeof(*in), CKPT_HDR_SOCKET_INET);
>> + if (IS_ERR(in))
>> + return PTR_ERR(in);
>> +
>> + /* Listening sockets and those that are closed but have a local
>> + * address need to call bind()
>> + */
>> + if ((h->sock.state == TCP_LISTEN) ||
>> + ((h->sock.state == TCP_CLOSE) && (h->laddr_len > 0))) {
>> + socket->sk->sk_reuse = 2;
>> + inet_sk(socket->sk)->freebind = 1;
>> + ret = socket->ops->bind(socket,
>> + (struct sockaddr *)l,
>> + h->laddr_len);
>> + ckpt_debug("inet bind: %i", ret);
>> + if (ret < 0)
>> + goto out;
>> +
>> + if (h->sock.state == TCP_LISTEN) {
>> + ret = socket->ops->listen(socket, h->sock.backlog);
>> + ckpt_debug("inet listen: %i", ret);
>> + if (ret < 0)
>> + goto out;
>> +
>> + ret = sock_add_parent(ctx, socket->sk);
>> + if (ret < 0)
>> + goto out;
JD> So this is just dummied off as a proof-of-concept for LISTEN?
I'm not sure what you mean...
>> + }
>> + } else {
>> + ret = sock_cptrst(ctx, socket->sk, h, CKPT_RST);
>> + if (ret)
>> + goto out;
>> +
>> + ret = sock_inet_cptrst(ctx, socket->sk, in, CKPT_RST);
>> + if (ret)
>> + goto out;
JD> At a minimum, you'll want to start the TCP retransmit timer if there is
JD> unacknowledged data outstanding. And other timers for other states, as
JD> they're supported.
JD> And you probably do want to do slow-start again--disregard my babbling
JD> from yesterday.
Heh, okay :)
JD> This is part of your AF_UNIX patch:
JD> struct socket *do_sock_file_restore(struct ckpt_ctx *ctx,
JD> struct ckpt_hdr_socket *h)
JD> {
JD> struct socket *socket;
JD> int ret;
JD> ret = sock_create(h->sock_common.family, h->sock.type, 0, &socket);
JD> if (ret < 0)
JD> return ERR_PTR(ret);
JD> You _really_ want to pass the actual protocol number to sock_create().
JD> The size of the sk it creates depends on this. You'll quickly be in
JD> memory corruption hell without it.
You mean I need to verify that the protocol is one of IPPROTO_TCP,
IPPROTO_UDP, or PF_UNIX, right?
JD> Also from the AF_UNIX patch:
JD> static int obj_sock_users(void *ptr)
JD> {
JD> return atomic_read(&((struct sock *) ptr)->sk_refcnt);
JD> }
JD> Network sockets also use sk->sk_wmem_alloc to track references to
JD> the sock from egress skb's
IIUC, this function is part of the framework's leak detection. That
code looks to make sure objects don't gain any additional users
between the start and end of the checkpoint operation. I think the
sk_refcnt satisfies that requirement here, no?
JD> And:
JD> static int sock_copy_buffers(struct sk_buff_head *from, struct
JD> sk_buff_head *to)
JD> {
JD> int count = 0;
JD> struct sk_buff *skb;
JD> skb_queue_walk(from, skb) {
JD> struct sk_buff *tmp;
JD> tmp = dev_alloc_skb(skb->len);
JD> if (!tmp)
JD> return -ENOMEM;
JD> spin_lock(&from->lock);
JD> skb_morph(tmp, skb);
JD> spin_unlock(&from->lock);
JD> Why not just clone the skb?
Okay, good call.
Thanks!
--
Dan Smith
IBM Linux Technology Center
email: danms@us.ibm.com
^ permalink raw reply
* [PATCH 5/9] drivers/net/wireless: correct error-handling code
From: Julia Lawall @ 2009-07-28 15:54 UTC (permalink / raw)
To: netdev, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
iwm_wdev_alloc returns an ERR_PTR value in an error case instead of NULL.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@match exists@
expression x, E;
statement S1, S2;
@@
x = iwm_wdev_alloc(...)
... when != x = E
(
* if (x == NULL || ...) S1 else S2
|
* if (x == NULL && ...) S1 else S2
)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/net/wireless/iwmc3200wifi/netdev.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index bb71f8a..e1c6693 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -99,7 +99,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
int ret = 0;
wdev = iwm_wdev_alloc(sizeof_bus, dev);
- if (!wdev) {
+ if (IS_ERR(wdev)) {
dev_err(dev, "no memory for wireless device instance\n");
return ERR_PTR(-ENOMEM);
}
^ permalink raw reply related
* Re: [RFC][PATCH 2/5] netfilter: xt_ipvs (netfilter matcher for ipvs)
From: Hannes Eder @ 2009-07-28 14:55 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: lvs-devel, netdev, netfilter-devel, linux-kernel
In-Reply-To: <alpine.LSU.2.00.0907272017280.20984@fbirervta.pbzchgretzou.qr>
On Mon, Jul 27, 2009 at 20:35, Jan Engelhardt<jengelh@medozas.de> wrote:
>
> On Monday 2009-07-27 15:46, Hannes Eder wrote:
>>--- /dev/null
>>+++ b/include/linux/netfilter/xt_ipvs.h
>>@@ -0,0 +1,32 @@
>>+#ifndef _XT_IPVS_H
>>+#define _XT_IPVS_H 1
>>+
>>+#ifndef _IP_VS_H
>
> Do the definitions (should probably be enums) exist in
> very old <linux/ip_vs.h>? Then maybe you can get rid of them
> from xt_ipvs.h.
Definitions removed from xt_ipvs.h. For xt_ipvs.c I just included
linux/ip_vs.h. For libxt_ipvs (user space library) I added the entire
linux/ip_vs.h. Do you think this is better?
>>+#define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */
>>+#define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */
>>+#define IP_VS_CONN_F_LOCALNODE 0x0001 /* local node */
>>+#define IP_VS_CONN_F_TUNNEL 0x0002 /* tunneling */
>>+#define IP_VS_CONN_F_DROUTE 0x0003 /* direct routing */
>>+#define IP_VS_CONN_F_BYPASS 0x0004 /* cache bypass */
>>+#endif
>>+
>>+#define XT_IPVS_IPVS 0x01 /* this is implied by all other options */
>>+#define XT_IPVS_PROTO 0x02
>>+#define XT_IPVS_VADDR 0x04
>>+#define XT_IPVS_VPORT 0x08
>>+#define XT_IPVS_DIR 0x10
>>+#define XT_IPVS_METHOD 0x20
>>+#define XT_IPVS_MASK (0x40 - 1)
>>+#define XT_IPVS_ONCE_MASK (XT_IPVS_MASK & ~XT_IPVS_IPVS)
>>+
>>+struct xt_ipvs {
>>+ union nf_inet_addr vaddr, vmask;
>>+ __be16 vport;
>>+ u_int16_t l4proto;
>>+ u_int16_t fwd_method;
>>+
>>+ u_int8_t invert;
>>+ u_int8_t bitmask;
>>+};
>
> As per the "Writing Netfilter modules" e-book, __u16/__u8 is required.
Done.
>>+config NETFILTER_XT_MATCH_IPVS
>>+ tristate '"ipvs" match support'
>>+ depends on NETFILTER_ADVANCED
>>+ help
>>+ This option allows you to match against ipvs properties of a packet.
>>+
>>+ To compile it as a module, choos M here. If unsure, say N.
>>+
>IMHO the "to compile it as a module, choos[e] M" is a relict from
> old times and should just be dropped. These days, I stupilate,
> everyone knows that M makes modules. And if it doesnot, then
> it's not allowed by Kconfig :>
Done.
>>+MODULE_AUTHOR("Hannes Eder <heder@google.com>");
>>+MODULE_DESCRIPTION("Xtables: match ipvs");
>
> "Match IPVS connection properties" is what you previously stated,
> and which I think is good. Use it here, too.
Done.
>>+bool ipvs_mt(const struct sk_buff *skb, const struct xt_match_param *par)
>>+{
>>+ const struct xt_ipvs *data = par->matchinfo;
>>+ const u_int8_t family = par->family;
>>+ struct ip_vs_iphdr iph;
>>+ struct ip_vs_protocol *pp;
>>+ struct ip_vs_conn *cp;
>>+ int af;
>>+ bool match = true;
>>+
>>+ if (data->bitmask == XT_IPVS_IPVS) {
>>+ match = !!(skb->ipvs_property)
>>+ ^ !!(data->invert & XT_IPVS_IPVS);
>>+ goto out;
>>+ }
>
> XT_IPVS_IPVS? What's that supposed to tell me...
Just matching aginst the skb->ipvs_property, I changed to name to
XT_IPVS_IPVS_PROPERTY.
> Anyway, this can be made much shorter, given that all following
> the "out" label is a return:
You are right. For the moment, I'll keep it as is. Having a single
entry/exit point makes it easier to instrument the function for
debugging.
>
> if (data->bitmask == XT_IPVS_IPVS)
> return skb->ipvs_property ^ !!(data->invert & XT_IPVS_IPVS);
>
>>+ /* other flags than XT_IPVS_IPVS are set */
>>+ if (!skb->ipvs_property) {
>>+ match = false;
>>+ goto out;
>>+ }
>
> if (!skb->ipvs_property)
> return false;
>
>>+ ip_vs_fill_iphdr(af, skb_network_header(skb), &iph);
>>+
>>+ if (data->bitmask & XT_IPVS_PROTO)
>>+ if ((iph.protocol == data->l4proto)
>>+ ^ !(data->invert & XT_IPVS_PROTO)) {
>>+ match = false;
>>+ goto out;
>>+ }
>
> if (iph.protocol == data->l4proto ^
> !(data->invert & XT_IPVS_PROTO))
> return false;
>
>>+ pp = ip_vs_proto_get(iph.protocol);
>>+ if (unlikely(!pp)) {
>>+ match = false;
>>+ goto out;
>>+ }
>
> if (unlikely(pp == NULL))
> return false;
>
> Only after here we really need goto (to put pp).
>
>>+ /*
>>+ * Check if the packet belongs to an existing entry
>>+ */
>>+ /* TODO: why does it only match in inverse? */
>
> FIXME: Figure it out :)
Still working on that ;)
>>+ cp = pp->conn_out_get(af, skb, pp, &iph, iph.len, 1 /* inverse */);
>>+ if (unlikely(!cp)) {
>>+ match = false;
>>+ goto out;
>>+ }
>>+
>>+ /*
>>+ * We found a connection, i.e. ct != 0, make sure to call
>>+ * __ip_vs_conn_put before returning. In our case jump to out_put_con.
>>+ */
>>+
>>+ if (data->bitmask & XT_IPVS_VPORT)
>>+ if ((cp->vport == data->vport)
>>+ ^ !(data->invert & XT_IPVS_VPORT)) {
>>+ match = false;
>>+ goto out_put_ct;
>>+ }
>>+
>>+ if (data->bitmask & XT_IPVS_DIR) {
>>+ /* TODO: implement */
>
> /* Yes please */
Here we go:
if (data->bitmask & XT_IPVS_DIR) {
enum ip_conntrack_info ctinfo;
struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
if (ct == NULL || ct == &nf_conntrack_untracked) {
match = false;
goto out_put_cp;
}
if ((ctinfo >= IP_CT_IS_REPLY) ^
!!(data->invert & XT_IPVS_DIR)) {
match = false;
goto out_put_cp;
}
}
>>+ }
>>+
>>+ if (data->bitmask & XT_IPVS_METHOD)
>>+ if (((cp->flags & IP_VS_CONN_F_FWD_MASK) == data->fwd_method)
>>+ ^ !(data->invert & XT_IPVS_METHOD)) {
>>+ match = false;
>>+ goto out_put_ct;
>>+ }
>>+
>>+ if (data->bitmask & XT_IPVS_VADDR) {
>>+ if (af != family) {
>>+ match = false;
>>+ goto out_put_ct;
>>+ }
>>+
>>+ if (ipvs_mt_addrcmp(&cp->vaddr, &data->vaddr, &data->vmask, af)
>>+ ^ !(data->invert & XT_IPVS_VADDR)) {
>
> I think the operator (^ in this case) always goes onto the same line as the ')'
> ((a) ^\n(b), not ((a)\n ^(b)), though some legacy code seems to do it
> random so-so.)
I changed it as suggested, though I could not find anything in
Documentation/CodingStyle about that.
>>+ return match;
>>+}
>>+EXPORT_SYMBOL(ipvs_mt);
>
> What will be using ipvs_mt?
Nobody, EXPORT_SYMBOL removed.
>>+static struct xt_match xt_ipvs_mt_reg[] __read_mostly = {
>>+ {
>>+ .name = "ipvs",
>>+ .revision = 0,
>>+ .family = NFPROTO_UNSPEC,
>>+ .match = ipvs_mt,
>>+ .matchsize = sizeof(struct xt_ipvs),
>>+ .me = THIS_MODULE,
>>+ },
>>+};
>
> There is just one element, so no strict need for the [] array.
You are right. Done.
Thanks for the review.
Cheers,
-Hannes
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH V2] CAN: Add Flexcan CAN controller driver
From: Sascha Hauer @ 2009-07-28 14:53 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: Socketcan-core, Linux Netdev List
In-Reply-To: <4A6F0FC2.1060605@hartkopp.net>
On Tue, Jul 28, 2009 at 04:48:34PM +0200, Oliver Hartkopp wrote:
> Sascha Hauer wrote:
> > On Tue, Jul 28, 2009 at 04:12:10PM +0200, Oliver Hartkopp wrote:
> >> Oliver Hartkopp wrote:
> >>> Sascha Hauer wrote:
> >>>>>> +
> >>>>>> + if (frame->can_id & CAN_RTR_FLAG)
> >>>>>> + dlc |= MB_CNT_RTR;
> >>>>>> +
> >>>>>> + writel(dlc, ®s->cantxfg[TX_BUF_ID].can_dlc);
> >>>>>> + writel(can_id, ®s->cantxfg[TX_BUF_ID].can_id);
> >> Are you sure, that this is correct?
> >
> > Yes, I am sure, at least on my hardware.
>
> I looked into the writel() macro which does a cpu_to_le32() to the value -
> sorry that i did not check this before ...
>
> >
> >> Indeed i wonder, if it would make sense to skip the entire struct flexcan_mb
> >> approach and fiddle byte-by-byte inside the registers ...
> >
> > You'll have to to 32 bit accesses to get it right on little and big
> > endian.
> >
> > what we can do is:
> >
> > writel(can_data[0] << 24 | can_data[1] << 16 | can_data[2] << 8 | can_data[3],
> > msg_buf + 0x8);
>
> This looks easier to understand and makes things clear, when you look into the
> specification.
Ok, I'll change it like this.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply
* Re: [PATCH V2] CAN: Add Flexcan CAN controller driver
From: Oliver Hartkopp @ 2009-07-28 14:48 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Socketcan-core, Linux Netdev List
In-Reply-To: <20090728142452.GW2714@pengutronix.de>
Sascha Hauer wrote:
> On Tue, Jul 28, 2009 at 04:12:10PM +0200, Oliver Hartkopp wrote:
>> Oliver Hartkopp wrote:
>>> Sascha Hauer wrote:
>>>>>> +
>>>>>> + if (frame->can_id & CAN_RTR_FLAG)
>>>>>> + dlc |= MB_CNT_RTR;
>>>>>> +
>>>>>> + writel(dlc, ®s->cantxfg[TX_BUF_ID].can_dlc);
>>>>>> + writel(can_id, ®s->cantxfg[TX_BUF_ID].can_id);
>> Are you sure, that this is correct?
>
> Yes, I am sure, at least on my hardware.
I looked into the writel() macro which does a cpu_to_le32() to the value -
sorry that i did not check this before ...
>
>> Indeed i wonder, if it would make sense to skip the entire struct flexcan_mb
>> approach and fiddle byte-by-byte inside the registers ...
>
> You'll have to to 32 bit accesses to get it right on little and big
> endian.
>
> what we can do is:
>
> writel(can_data[0] << 24 | can_data[1] << 16 | can_data[2] << 8 | can_data[3],
> msg_buf + 0x8);
This looks easier to understand and makes things clear, when you look into the
specification.
Regards,
Oliver
^ permalink raw reply
* Re: [PATCH] net: shrink net_device by #ifdef-ing protocol-specific members
From: Octavian Purdila @ 2009-07-28 14:43 UTC (permalink / raw)
To: David Miller; +Cc: lgrijincu, netdev, eric.dumazet
In-Reply-To: <20090727.082644.265102452.davem@davemloft.net>
On Monday 27 July 2009 18:26:44 David Miller wrote:
> From: Lucian Adrian Grijincu <lgrijincu@ixiacom.com>
> Date: Mon, 27 Jul 2009 18:09:08 +0300
>
> > Some members of net_device are used only by some protocols.
> >
> > If those protocols are not compiled (as modules or linked in) they
> > should not take up space in the structure.
>
> This benefits, at best, %0.000000001 of users of the Linux kernel,
> because every distribution is going to turn on every single option.
>
Not all Linux users are using regular (desktop/server) distributions. Linux is
used in embedded systems as well and in these case it makes sense to turn off
ax25/econet/decnet and in some cases even wireless/ipv6.
> If you want to shrink structures, find ways to eliminate or
> shrink structure members in all cases.
We are looking into that as well since we have a pretty aggressive goal (get
net_device to 450 bytes or so), but we thought of starting with the low
hanging fruits.
Any suggestions in this area?
tavi
^ permalink raw reply
* Re: ixgbe: panic in ixgbe_clean_rx_irq()
From: Todd Merritt @ 2009-07-28 13:37 UTC (permalink / raw)
To: Waskiewicz Jr, Peter P; +Cc: netdev@vger.kernel.org
In-Reply-To: <Pine.WNT.4.64.0907271530400.5004@ppwaskie-MOBL2.amr.corp.intel.com>
No, we're running the stock kernel. We can reliably reproduce it here.
Please let me know if there's anything we can do to help you with
providing a fix.
Thanks,
Todd
Waskiewicz Jr, Peter P wrote:
> On Mon, 27 Jul 2009, Todd Merritt wrote:
>
>
>> We're getting a panic in the same function with the stable version of the ixgbe
>> driver 2.0.38.2-1 on redhat 5 kernel-2.6.18-128.1.10.el5. Is there a dev
>> release of the driver that might have a fix in it ?
>>
>
> Are you also running with preemption enabled? We're having a very tough
> time reproducing this bug in our lab, so no, we don't have any fix for it
> yet.
>
> -PJ
>
>
^ permalink raw reply
* Re: [PATCH] pppol2tp: calls unregister_pernet_gen_device() at unload time
From: Cyrill Gorcunov @ 2009-07-28 14:29 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Pavel Emelyanov, Igor M Podlesny, Andrew Morton,
netdev
In-Reply-To: <4A6F017B.4060909@gmail.com>
[Eric Dumazet - Tue, Jul 28, 2009 at 03:47:39PM +0200]
| Eric Dumazet a écrit :
| > Seems drivers/net/pppol2tp.c is a suspect...
| >
| > It uses register_pernet_gen_device() from pppol2tp_init()
| > but doesnt call unregister_pernet_gen_device()
|
| OK patch seems really easy...
|
| This bug was added in commit 4e9fb8016a351b5b9da7fea32bcfdbc9d836e421
| net: pppol2tp - introduce net-namespace functionality
|
| So this is a stable candidate I guess ?
|
| Thank you
Thanks a lot Eric!
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
-- Cyrill
^ permalink raw reply
* Re: [PATCH V2] CAN: Add Flexcan CAN controller driver
From: Sascha Hauer @ 2009-07-28 14:24 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: Socketcan-core, Linux Netdev List
In-Reply-To: <4A6F073A.1050909@hartkopp.net>
On Tue, Jul 28, 2009 at 04:12:10PM +0200, Oliver Hartkopp wrote:
> Oliver Hartkopp wrote:
> > Sascha Hauer wrote:
>
> >>>> +
> >>>> + if (frame->can_id & CAN_RTR_FLAG)
> >>>> + dlc |= MB_CNT_RTR;
> >>>> +
> >>>> + writel(dlc, ®s->cantxfg[TX_BUF_ID].can_dlc);
> >>>> + writel(can_id, ®s->cantxfg[TX_BUF_ID].can_id);
>
> Are you sure, that this is correct?
Yes, I am sure, at least on my hardware.
>
> Indeed i wonder, if it would make sense to skip the entire struct flexcan_mb
> approach and fiddle byte-by-byte inside the registers ...
You'll have to to 32 bit accesses to get it right on little and big
endian.
what we can do is:
writel(can_data[0] << 24 | can_data[1] << 16 | can_data[2] << 8 | can_data[3],
msg_buf + 0x8);
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ 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