* [PATCH net-next-2.6 7/9] sctp: fix to check the source address of COOKIE-ECHO chunk
From: Wei Yongjun @ 2011-04-20 7:30 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org, lksctp
In-Reply-To: <4DAE8A27.3040007@cn.fujitsu.com>
SCTP does not check whether the source address of COOKIE-ECHO
chunk is the original address of INIT chunk or part of the any
address parameters saved in COOKIE in CLOSED state. So even if
the COOKIE-ECHO chunk is from any address but with correct COOKIE,
the COOKIE-ECHO chunk still be accepted. If the COOKIE is not from
a valid address, the assoc should not be established.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
include/net/sctp/structs.h | 2 +-
net/sctp/sm_make_chunk.c | 26 +++++++++++++++++++++-----
net/sctp/sm_sideeffect.c | 3 +--
net/sctp/sm_statefuns.c | 14 +++++---------
4 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 0f6e60a..5c9bada 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1400,7 +1400,7 @@ int sctp_has_association(const union sctp_addr *laddr,
int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t,
sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk,
struct sctp_chunk **err_chunk);
-int sctp_process_init(struct sctp_association *, sctp_cid_t cid,
+int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk,
const union sctp_addr *peer,
sctp_init_chunk_t *init, gfp_t gfp);
__u32 sctp_generate_tag(const struct sctp_endpoint *);
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index f87ccb1..a7b65e9 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2242,14 +2242,17 @@ int sctp_verify_init(const struct sctp_association *asoc,
* Returns 0 on failure, else success.
* FIXME: This is an association method.
*/
-int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
+int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
const union sctp_addr *peer_addr,
sctp_init_chunk_t *peer_init, gfp_t gfp)
{
union sctp_params param;
struct sctp_transport *transport;
struct list_head *pos, *temp;
+ struct sctp_af *af;
+ union sctp_addr addr;
char *cookie;
+ int src_match = 0;
/* We must include the address that the INIT packet came from.
* This is the only address that matters for an INIT packet.
@@ -2261,18 +2264,31 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
* added as the primary transport. The source address seems to
* be a a better choice than any of the embedded addresses.
*/
- if (peer_addr) {
- if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
- goto nomem;
- }
+ if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
+ goto nomem;
+
+ if (sctp_cmp_addr_exact(sctp_source(chunk), peer_addr))
+ src_match = 1;
/* Process the initialization parameters. */
sctp_walk_params(param, peer_init, init_hdr.params) {
+ if (!src_match && (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||
+ param.p->type == SCTP_PARAM_IPV6_ADDRESS)) {
+ af = sctp_get_af_specific(param_type2af(param.p->type));
+ af->from_addr_param(&addr, param.addr,
+ chunk->sctp_hdr->source, 0);
+ if (sctp_cmp_addr_exact(sctp_source(chunk), &addr))
+ src_match = 1;
+ }
if (!sctp_process_param(asoc, param, peer_addr, gfp))
goto clean_up;
}
+ /* source address of chunk may not match any valid address */
+ if (!src_match)
+ goto clean_up;
+
/* AUTH: After processing the parameters, make sure that we
* have all the required info to potentially do authentications.
*/
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 3b80fe2..d612ca1 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -595,8 +595,7 @@ static int sctp_cmd_process_init(sctp_cmd_seq_t *commands,
* fail during INIT processing (due to malloc problems),
* just return the error and stop processing the stack.
*/
- if (!sctp_process_init(asoc, chunk->chunk_hdr->type,
- sctp_source(chunk), peer_init, gfp))
+ if (!sctp_process_init(asoc, chunk, sctp_source(chunk), peer_init, gfp))
error = -ENOMEM;
else
error = 0;
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index ad3b43b..ab94932 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -393,8 +393,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep,
goto nomem_init;
/* The call, sctp_process_init(), can fail on memory allocation. */
- if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,
- sctp_source(chunk),
+ if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk),
(sctp_init_chunk_t *)chunk->chunk_hdr,
GFP_ATOMIC))
goto nomem_init;
@@ -725,7 +724,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
*/
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
- if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,
+ if (!sctp_process_init(new_asoc, chunk,
&chunk->subh.cookie_hdr->c.peer_addr,
peer_init, GFP_ATOMIC))
goto nomem_init;
@@ -1464,8 +1463,7 @@ static sctp_disposition_t sctp_sf_do_unexpected_init(
* Verification Tag and Peers Verification tag into a reserved
* place (local tie-tag and per tie-tag) within the state cookie.
*/
- if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,
- sctp_source(chunk),
+ if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk),
(sctp_init_chunk_t *)chunk->chunk_hdr,
GFP_ATOMIC))
goto nomem;
@@ -1694,8 +1692,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_a(const struct sctp_endpoint *ep,
*/
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
- if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,
- sctp_source(chunk), peer_init,
+ if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init,
GFP_ATOMIC))
goto nomem;
@@ -1780,8 +1777,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep,
* side effects--it is safe to run them here.
*/
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
- if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type,
- sctp_source(chunk), peer_init,
+ if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init,
GFP_ATOMIC))
goto nomem;
--
1.6.5.2
^ permalink raw reply related
* [PATCH net-next-2.6 8/9] sctp: make heartbeat information in sctp_make_heartbeat()
From: Wei Yongjun @ 2011-04-20 7:31 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org, lksctp
In-Reply-To: <4DAE8A27.3040007@cn.fujitsu.com>
Make heartbeat information in sctp_make_heartbeat() instead
of make it in sctp_sf_heartbeat() directly for common using.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
include/net/sctp/sm.h | 4 +---
net/sctp/sm_make_chunk.c | 18 +++++++++++++-----
net/sctp/sm_statefuns.c | 11 +----------
3 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 9352d12..652f09b 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -232,9 +232,7 @@ struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *,
const struct sctp_chunk *,
struct sctp_paramhdr *);
struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *,
- const struct sctp_transport *,
- const void *payload,
- const size_t paylen);
+ const struct sctp_transport *);
struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *,
const struct sctp_chunk *,
const void *payload,
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index a7b65e9..58eb27f 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1075,20 +1075,28 @@ nodata:
/* Make a HEARTBEAT chunk. */
struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
- const struct sctp_transport *transport,
- const void *payload, const size_t paylen)
+ const struct sctp_transport *transport)
{
- struct sctp_chunk *retval = sctp_make_chunk(asoc, SCTP_CID_HEARTBEAT,
- 0, paylen);
+ struct sctp_chunk *retval;
+ sctp_sender_hb_info_t hbinfo;
+
+ retval = sctp_make_chunk(asoc, SCTP_CID_HEARTBEAT, 0, sizeof(hbinfo));
if (!retval)
goto nodata;
+ hbinfo.param_hdr.type = SCTP_PARAM_HEARTBEAT_INFO;
+ hbinfo.param_hdr.length = htons(sizeof(sctp_sender_hb_info_t));
+ hbinfo.daddr = transport->ipaddr;
+ hbinfo.sent_at = jiffies;
+ hbinfo.hb_nonce = transport->hb_nonce;
+
/* Cast away the 'const', as this is just telling the chunk
* what transport it belongs to.
*/
retval->transport = (struct sctp_transport *) transport;
- retval->subh.hbs_hdr = sctp_addto_chunk(retval, paylen, payload);
+ retval->subh.hbs_hdr = sctp_addto_chunk(retval, sizeof(hbinfo),
+ &hbinfo);
nodata:
return retval;
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index ab94932..736847e 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -941,18 +941,9 @@ static sctp_disposition_t sctp_sf_heartbeat(const struct sctp_endpoint *ep,
{
struct sctp_transport *transport = (struct sctp_transport *) arg;
struct sctp_chunk *reply;
- sctp_sender_hb_info_t hbinfo;
- size_t paylen = 0;
-
- hbinfo.param_hdr.type = SCTP_PARAM_HEARTBEAT_INFO;
- hbinfo.param_hdr.length = htons(sizeof(sctp_sender_hb_info_t));
- hbinfo.daddr = transport->ipaddr;
- hbinfo.sent_at = jiffies;
- hbinfo.hb_nonce = transport->hb_nonce;
/* Send a heartbeat to our peer. */
- paylen = sizeof(sctp_sender_hb_info_t);
- reply = sctp_make_heartbeat(asoc, transport, &hbinfo, paylen);
+ reply = sctp_make_heartbeat(asoc, transport);
if (!reply)
return SCTP_DISPOSITION_NOMEM;
--
1.6.5.2
^ permalink raw reply related
* [PATCH] bnx2x: dont dereference tcp header on non tcp frames
From: Eric Dumazet @ 2011-04-20 7:31 UTC (permalink / raw)
To: Dmitry Kravkov, David Miller; +Cc: Eilon Greenstein, netdev
In-Reply-To: <1303229503.3480.386.camel@edumazet-laptop>
Le mardi 19 avril 2011 à 18:11 +0200, Eric Dumazet a écrit :
> Hi guys
>
> bnx2x_set_pbd_csum() / bnx2x_set_pbd_csum_e2() seem to read
> tcp_hdrlen(skb) even for non TCP frames ?
>
> Also, (skb_network_header(skb) - skb->data) is signed, so
> (skb_network_header(skb) - skb->data) / 2 is a bit expensive...
>
I managed to trigger a kmemcheck fault using netperf -t UDP_RR
02:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM57711E 10Gigabit PCIe
[ 341.246514] WARNING: kmemcheck: Caught 8-bit read from uninitialized memory (ffff88011800ec30)
[ 341.247155] c0a8146ea907c4550009aa456ed2000008000400040000001400030000000000
[ 341.249789] i i i i i i i i i i i i i u u u u u u u u u u u u u u u u u u u
[ 341.252425] ^
[ 341.252773]
[ 341.252937] Pid: 4122, comm: netperf Not tainted 2.6.39-rc4-00237-ge3de956-dirty #549 HP ProLiant BL460c G6
[ 341.253768] RIP: 0010:[<ffffffff812f5224>] [<ffffffff812f5224>] bnx2x_start_xmit+0xce4/0x13f0
[ 341.254476] RSP: 0018:ffff8801158b38b8 EFLAGS: 00010286
[ 341.254879] RAX: ffff88011800ec24 RBX: ffff880118e44820 RCX: 0000000000000007
[ 341.255400] RDX: 000000000000000a RSI: ffff880118e44820 RDI: ffff88011800ec40
[ 341.255918] RBP: ffff8801158b39b8 R08: ffff88011800ec40 R09: ffff88011800ec00
[ 341.256439] R10: 0000000000000000 R11: 000000006e14a8c0 R12: ffff880118f4db00
[ 341.256958] R13: 0000000000000481 R14: 0000000000000040 R15: ffff880118ff18e0
[ 341.257479] FS: 0000000000000000(0000) GS:ffff88011fc00000(0063) knlGS:00000000f77e16c0
[ 341.258081] CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b
[ 341.258511] CR2: ffff880119856058 CR3: 0000000115879000 CR4: 00000000000006f0
[ 341.259033] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 341.259551] DR3: 0000000000000000 DR6: 00000000ffff4ff0 DR7: 0000000000000400
[ 341.260072] [<ffffffff8137fac5>] dev_hard_start_xmit+0x365/0x690
[ 341.260593] [<ffffffff81398bf7>] sch_direct_xmit+0xb7/0x1c0
[ 341.261091] [<ffffffff81383da8>] dev_queue_xmit+0x1a8/0x5d0
[ 341.261583] [<ffffffff813c2842>] ip_finish_output+0x122/0x2f0
[ 341.262122] [<ffffffff813c163e>] ip_output+0x7e/0xc0
[ 341.262609] [<ffffffff813c1194>] ip_local_out+0x24/0x30
[ 341.263114] [<ffffffff813c11b6>] ip_send_skb+0x16/0x70
[ 341.263611] [<ffffffff813e1326>] udp_send_skb+0x126/0x380
[ 341.264129] [<ffffffff813e300c>] udp_sendmsg+0x2cc/0x790
[ 341.264637] [<ffffffff813eaf44>] inet_sendmsg+0x84/0xc0
[ 341.265143] [<ffffffff8136d98b>] sock_sendmsg+0xbb/0xf0
[ 341.265646] [<ffffffff8136e1e5>] sys_sendto+0x105/0x140
[ 341.266151] [<ffffffff8136e22f>] sys_send+0xf/0x20
[ 341.266625] [<ffffffff813969fd>] compat_sys_socketcall+0xfd/0x1f0
[ 341.267186] [<ffffffff8146b8e9>] sysenter_dispatch+0x7/0x27
[PATCH] bnx2x: dont dereference tcp header on non tcp frames
bnx2x_set_pbd_csum() & bnx2x_set_pbd_csum_e2() use
tcp_hdrlen(skb) even for non TCP frames
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Dmitry Kravkov <dmitry@broadcom.com>
Cc: Eilon Greenstein <eilong@broadcom.com>
---
drivers/net/bnx2x/bnx2x_cmn.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index e83ac6d..a16a638 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -2019,7 +2019,9 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb,
static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb,
u32 *parsing_data, u32 xmit_type)
{
- *parsing_data |= ((tcp_hdrlen(skb)/4) <<
+ u8 tcphlen = (xmit_type & XMIT_CSUM_TCP) ? tcp_hdrlen(skb) : 0;
+
+ *parsing_data |= ((tcphlen/4) <<
ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) &
ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW;
@@ -2027,7 +2029,7 @@ static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb,
ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) &
ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W;
- return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data;
+ return skb_transport_header(skb) + tcphlen - skb->data;
}
/**
@@ -2044,6 +2046,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb,
u32 xmit_type)
{
u8 hlen = (skb_network_header(skb) - skb->data) / 2;
+ u8 tcphlen = (xmit_type & XMIT_CSUM_TCP) ? tcp_hdrlen(skb) : 0;
/* for now NS flag is not used in Linux */
pbd->global_data =
@@ -2053,7 +2056,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb,
pbd->ip_hlen_w = (skb_transport_header(skb) -
skb_network_header(skb)) / 2;
- hlen += pbd->ip_hlen_w + tcp_hdrlen(skb) / 2;
+ hlen += pbd->ip_hlen_w + tcphlen / 2;
pbd->total_hlen_w = cpu_to_le16(hlen);
hlen = hlen*2;
^ permalink raw reply related
* [PATCH net-next-2.6 9/9] sctp: move chunk from retransmit queue to abandoned list
From: Wei Yongjun @ 2011-04-20 7:32 UTC (permalink / raw)
To: David Miller; +Cc: netdev@vger.kernel.org, lksctp
In-Reply-To: <4DAE8A27.3040007@cn.fujitsu.com>
If there is still data waiting to retransmit and remain in
retransmit queue, while doing the next retransmit, if the
chunk is abandoned, we should move it to abandoned list.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
net/sctp/outqueue.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 3e9d8d2..1c88c89 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -577,6 +577,13 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
* try to send as much as possible.
*/
list_for_each_entry_safe(chunk, chunk1, lqueue, transmitted_list) {
+ /* If the chunk is abandoned, move it to abandoned list. */
+ if (sctp_chunk_abandoned(chunk)) {
+ list_del_init(&chunk->transmitted_list);
+ sctp_insert_list(&q->abandoned,
+ &chunk->transmitted_list);
+ continue;
+ }
/* Make sure that Gap Acked TSNs are not retransmitted. A
* simple approach is just to move such TSNs out of the
--
1.6.5.2
^ permalink raw reply related
* Re: [PATCH v2] net: filter: Just In Time compiler
From: Avi Kivity @ 2011-04-20 7:41 UTC (permalink / raw)
To: Eric Dumazet
Cc: Hagen Paul Pfeifer, David Miller, netdev,
Arnaldo Carvalho de Melo, Ben Hutchings
In-Reply-To: <1302797147.3248.32.camel@edumazet-laptop>
On 04/14/2011 07:05 PM, Eric Dumazet wrote:
> Le jeudi 14 avril 2011 à 18:53 +0300, Avi Kivity a écrit :
>
> > IMO, it will. I'll try to have gcc optimize your example filter later.
>
> Sure you can JIT a C program from bpf. It should take maybe 30 minutes.
> It certainly is more easy than JIT an binary/assembly code :)
>
> Now take a look how I call slowpath, I am not sure gcc will actually
> generate better code because of C conventions.
Some things will be the same (like calling a function outside the jit).
Some things will be faster.
> Loading a filter should be fast.
> Invoking a compiler is just too much work for BPF.
> Remember loading a filter is available to any user.
Like I mentioned before, use the interpreter until the result of the
jitter is available.
> This idea would be good for netfilter stuff, because we dont load
> iptables rules that often.
>
> But still, the netfilter mainloop can be converted as a kernel JIT, most
> probably. All the complex stuff (matches, targets) must call external
> procedures anyway.
We could convert some matches to bytecode, probably.
To avoid getting into an infinite loop (btw, does you jit avoid infinite
loops in the generated code?) I'll restate what I think are an external
jit's advantages and then stop harping on the subject:
- less effort
- less kernel code
- better arch support
- better optimization
- better profiler/debugger integration
- multiple optimization levels (can use your jitter in userspace, or
gcc, or llvm)
--
error compiling committee.c: too many arguments to function
^ permalink raw reply
* Re: [Bugme-new] [Bug 33502] New: Caught 64-bit read from uninitialized memory in __alloc_skb
From: Pekka Enberg @ 2011-04-20 7:49 UTC (permalink / raw)
To: casteyde.christian
Cc: Eric Dumazet, Christoph Lameter, Andrew Morton, netdev,
bugzilla-daemon, bugme-daemon, Vegard Nossum
In-Reply-To: <1303285519.4dae8f0fdf9b1@imp.free.fr>
On 4/20/11 10:45 AM, casteyde.christian@free.fr wrote:
> Indeed I can reproduce each time I boot, however I didn't managed to apply the
> patch to test it on -rc3 (neither -rc4), only the first hunk passed.
That's odd. Eric?
> I simply boot on this laptop with kmemcheck activated to get the warning, with
> vanilla -rc3. I've also tested -rc4 yersterday (without the patch therefore),
> the warning was not the same (it's a bit later, I will post the dmesg output on
> bugzilla tonight).
That's expected. You're unlikely to see the problem in the exact same
place across different kernel configs and versions.
Pekka
^ permalink raw reply
* Re: [Bugme-new] [Bug 33502] New: Caught 64-bit read from uninitialized memory in __alloc_skb
From: casteyde.christian @ 2011-04-20 7:45 UTC (permalink / raw)
To: Eric Dumazet
Cc: Pekka Enberg, Christoph Lameter, Andrew Morton, netdev,
bugzilla-daemon, bugme-daemon, casteyde.christian, Vegard Nossum
In-Reply-To: <1303279470.2756.17.camel@edumazet-laptop>
Quoting Eric Dumazet <eric.dumazet@gmail.com>:
> > Looks good to me! Can we get someone to test it as well?
>
> I tested first patch, but was not able to trigger the fault anyway
> without it. I'll try a bit more today if time permits...
>
> It would be nice if Christian can reproduce the initial problem easily
> and give us the steps...
>
>
>
>
Indeed I can reproduce each time I boot, however I didn't managed to apply the
patch to test it on -rc3 (neither -rc4), only the first hunk passed.
I simply boot on this laptop with kmemcheck activated to get the warning, with
vanilla -rc3. I've also tested -rc4 yersterday (without the patch therefore),
the warning was not the same (it's a bit later, I will post the dmesg output on
bugzilla tonight).
For info, my laptop is single core if that matters, it is preemptible, with
slub, 64bits, on an old CPU (Athlon64 3000 pre- lahf in 64bits).
^ permalink raw reply
* Re: [PATCH v2] net: xen-netback: convert to hw_features
From: Ian Campbell @ 2011-04-20 7:58 UTC (permalink / raw)
To: Michał Mirosław
Cc: David S. Miller, netdev@vger.kernel.org,
xen-devel@lists.xensource.com
In-Reply-To: <20110419133905.GA4716@rere.qmqm.pl>
On Tue, 2011-04-19 at 14:39 +0100, Michał Mirosław wrote:
> On Tue, Apr 19, 2011 at 03:35:06PM +0200, Michał Mirosław wrote:
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
> David, I was too quick with this, so please wait with this patch until Ian
> acks it again.
Thanks Michał.
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Ian.
^ permalink raw reply
* Re: [PATCH v2] net: filter: Just In Time compiler
From: Eric Dumazet @ 2011-04-20 8:07 UTC (permalink / raw)
To: Avi Kivity
Cc: Hagen Paul Pfeifer, David Miller, netdev,
Arnaldo Carvalho de Melo, Ben Hutchings
In-Reply-To: <4DAE8E47.7040409@redhat.com>
Le mercredi 20 avril 2011 à 10:41 +0300, Avi Kivity a écrit :
> On 04/14/2011 07:05 PM, Eric Dumazet wrote:
> > Le jeudi 14 avril 2011 à 18:53 +0300, Avi Kivity a écrit :
> >
> > > IMO, it will. I'll try to have gcc optimize your example filter later.
> >
> > Sure you can JIT a C program from bpf. It should take maybe 30 minutes.
> > It certainly is more easy than JIT an binary/assembly code :)
> >
> > Now take a look how I call slowpath, I am not sure gcc will actually
> > generate better code because of C conventions.
>
> Some things will be the same (like calling a function outside the jit).
> Some things will be faster.
>
> > Loading a filter should be fast.
> > Invoking a compiler is just too much work for BPF.
> > Remember loading a filter is available to any user.
>
> Like I mentioned before, use the interpreter until the result of the
> jitter is available.
>
> > This idea would be good for netfilter stuff, because we dont load
> > iptables rules that often.
> >
> > But still, the netfilter mainloop can be converted as a kernel JIT, most
> > probably. All the complex stuff (matches, targets) must call external
> > procedures anyway.
>
> We could convert some matches to bytecode, probably.
>
> To avoid getting into an infinite loop (btw, does you jit avoid infinite
> loops in the generated code?) I'll restate what I think are an external
> jit's advantages and then stop harping on the subject:
>
> - less effort
> - less kernel code
> - better arch support
> - better optimization
> - better profiler/debugger integration
> - multiple optimization levels (can use your jitter in userspace, or
> gcc, or llvm)
>
No problem, I'll wait your work on this then.
I disagree having a gcc on production machines, I'm not sure it will
please admins...
Thanks
^ permalink raw reply
* Re: [Bugme-new] [Bug 33502] New: Caught 64-bit read from uninitialized memory in __alloc_skb
From: Eric Dumazet @ 2011-04-20 8:09 UTC (permalink / raw)
To: Pekka Enberg
Cc: casteyde.christian, Christoph Lameter, Andrew Morton, netdev,
bugzilla-daemon, bugme-daemon, Vegard Nossum
In-Reply-To: <4DAE901C.2090809@cs.helsinki.fi>
Le mercredi 20 avril 2011 à 10:49 +0300, Pekka Enberg a écrit :
> On 4/20/11 10:45 AM, casteyde.christian@free.fr wrote:
> > Indeed I can reproduce each time I boot, however I didn't managed to apply the
> > patch to test it on -rc3 (neither -rc4), only the first hunk passed.
>
> That's odd. Eric?
>
I dont know, my patches were linux-2.6 based, and I pull tree very
often ;)
> > I simply boot on this laptop with kmemcheck activated to get the warning, with
> > vanilla -rc3. I've also tested -rc4 yersterday (without the patch therefore),
> > the warning was not the same (it's a bit later, I will post the dmesg output on
> > bugzilla tonight).
>
> That's expected. You're unlikely to see the problem in the exact same
> place across different kernel configs and versions.
>
Christian, please send us your .config
Thanks
^ permalink raw reply
* Re: [PATCH v2] net: filter: Just In Time compiler
From: David Miller @ 2011-04-20 8:12 UTC (permalink / raw)
To: avi; +Cc: eric.dumazet, hagen, netdev, acme, bhutchings
In-Reply-To: <4DAE8E47.7040409@redhat.com>
From: Avi Kivity <avi@redhat.com>
Date: Wed, 20 Apr 2011 10:41:59 +0300
> To avoid getting into an infinite loop (btw, does you jit avoid
> infinite loops in the generated code?) I'll restate what I think are
> an external jit's advantages and then stop harping on the subject:
Only forward branching is allowed in BPF code.
^ permalink raw reply
* Re: [PATCH v2] net: filter: Just In Time compiler
From: David Miller @ 2011-04-20 8:14 UTC (permalink / raw)
To: eric.dumazet; +Cc: avi, hagen, netdev, acme, bhutchings
In-Reply-To: <1303286878.3186.17.camel@edumazet-laptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 20 Apr 2011 10:07:58 +0200
> No problem, I'll wait your work on this then.
Don't, please resubmit your BPF jit code so I can apply it.
Waiting for some userspace pie-in-the-sky based solution, and blocking
this perfectly functional thing we have now meanwhile, is not
reasonable.
We're pragmatic, not perfectionists.
Thanks Eric.
^ permalink raw reply
* Re: [Bugme-new] [Bug 33502] New: Caught 64-bit read from uninitialized memory in __alloc_skb
From: Pekka Enberg @ 2011-04-20 8:21 UTC (permalink / raw)
To: Eric Dumazet
Cc: casteyde.christian, Christoph Lameter, Andrew Morton, netdev,
bugzilla-daemon, bugme-daemon, Vegard Nossum
In-Reply-To: <1303286998.3186.18.camel@edumazet-laptop>
On 4/20/11 11:09 AM, Eric Dumazet wrote:
> Le mercredi 20 avril 2011 à 10:49 +0300, Pekka Enberg a écrit :
>> On 4/20/11 10:45 AM, casteyde.christian@free.fr wrote:
>>> Indeed I can reproduce each time I boot, however I didn't managed to apply the
>>> patch to test it on -rc3 (neither -rc4), only the first hunk passed.
>>
>> That's odd. Eric?
>>
>
> I dont know, my patches were linux-2.6 based, and I pull tree very
> often ;)
Btw, the patch applies fine here on top of 2.6.39-rc4.
^ permalink raw reply
* Re: A patch you wrote some time ago (aka: "[patch 41/54] ICMP: Fix icmp_errors_use_inbound_ifaddr sysctl")
From: Patrick McHardy @ 2011-04-20 8:24 UTC (permalink / raw)
To: Chris Wright; +Cc: Alexander Hoogerhuis, linux-kernel, netdev
In-Reply-To: <20110419165411.GO9569@sequoia.sous-sol.org>
On 19.04.2011 18:54, Chris Wright wrote:
> * Alexander Hoogerhuis (alexh@boxed.no) wrote:
>> I hope you (or anyone else) can spare half a minute to have a quick
>> look at a patch you wrote a few years ago:
>>
>>> http://lkml.org/lkml/2007/6/8/124
>
> I actually did not write that patch, rather added it to the -stable tree.
> Patrick (CCd) wrote it.
I actually only fixed it, it was added in 1c2fb7f9 by J. Simonetti
<jeroen@simonetti.nl>. Anyways ...
>> I've been tracking down a case of ICMP Redirects originating from
>> the wrong IPs, and as far I can tell, you patch is the last to touch
>> this code (net/ipv4/icmp.c:507):
>>
>>> if (rt->fl.iif && net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr)
>>> dev = dev_get_by_index_rcu(net, rt->fl.iif);
>>>
>>> if (dev)
>>> saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
>>> else
>>> saddr = 0;
>>
>> In a plain world this would work, but I have come across a case that
>> seems to be not handled by this.
>>
>> I have two machines set up with VRRP to act as routers out of a
>> subnet, and they have IPs x.x.x.13/28 and x.x.x.14/28, with VRRP
>> holding on to x.x.x.1/28.
>>
>> If a node in x.x.x.0/28 needs to get a ICMP redirect from x.x.x.1/28
>> (to reach another subnet behind a different gateway in x.x.x.0/28),
>> then the source IP on the ICMP redirect is chosen as the primary IP
>> on the interface that the packet arrived at.
>>
>> This is as far as I can tell from RFCs and colleagues fine for most
>> things after you're routed one hop or more, but in the case of ICMP
>> redirect it means that the redirect is not adhered to by the client,
>> as it will get the reidrect from x.x.x.13/28, not x.x.x.1/28.
>>
>> inet_select_addr seems to be explicitly looking for the primary IP
>> in all cases (./net/ipv4/devinet.c:875), and in the case of sending
>> ICMP recdirect when in an VRRP setup, that would not work well. It
>> should try to match the actual inbound IP.
>From what I understand, its explicitly meant to behave this way.
This is what the original commit stated:
The new behaviour (when the sysctl variable is toggled on), it will send
the message with the ip of the interface that received the packet that
caused the icmp error. This is the behaviour network administrators will
expect from a router. It makes debugging complicated network layouts
much easier. Also, all 'vendor routers' I know of have the later
behaviour.
>> Judging by the comments from your patch I am not sure if the source
>> IP that triggers the ICMP redirect is available at this point any
>> more.
>>
>> The way I understand it should pick adress is this way:
>>
>>> if (rt->fl.iif && net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr)
>>> dev = dev_get_by_index_rcu(net, rt->fl.iif);
>>>
>>> if (dev == fl.iif)
>>> saddr = iph->daddr;
>>>
>>> if (dev != fl.iif)
>>> saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
>>> else
>>> saddr = 0;
>>
>> I.e. if we are replying to something that is from a local network
>> segment, then iph->daddr would be a more correct source. My C skill
>> is prehistoric so what I've written likely is far from correct, but
>> the general gist is that there is a special case for replying to
>> something local.
That might be a possibility to fix this for your case. But I'm
wondering why you're turning this on at all and not have routing
decide the correct source address?
^ permalink raw reply
* Re: [PATCHv2] usbnet: Resubmit interrupt URB more often
From: David Miller @ 2011-04-20 8:24 UTC (permalink / raw)
To: pstew; +Cc: netdev, bhutchings
In-Reply-To: <20110419175037.AADD22052B@glenhelen.mtv.corp.google.com>
From: Paul Stewart <pstew@chromium.org>
Date: Tue, 19 Apr 2011 10:44:12 -0700
> The second class of device are those which shut down the device
> during suspend. During a suspend-resume cycle, the device is
> re-enumerated at system resume, and for whatever reason
> usbnet_resume may be called on the device during the call-tree
> from usbnet_open-> usb_autopm_get_interface, which may cause a
> race where the first change above may cause the bh to submit the
> interrupt urb before usbnet_open() does. As a result, I've added
> an EALREADY check and a fix to urb.c to send one.
You'll need to submit the generic urb submission change via the USB
maintainers, not networking.
^ permalink raw reply
* Re: [PATCH v2] net: filter: Just In Time compiler
From: Hagen Paul Pfeifer @ 2011-04-20 8:27 UTC (permalink / raw)
To: David Miller; +Cc: eric.dumazet, avi, netdev, acme, bhutchings
In-Reply-To: <20110420.011454.226757908.davem@davemloft.net>
On Wed, 20 Apr 2011 01:14:54 -0700 (PDT), David Miller wrote:
I am fine with this patch too:
Acked-by: Hagen Paul Pfeifer <hagen@jauu.net>
Hopefully someone dig into the BPF optimizer in libpcap - cause there lie
the big optimization potential. Trivial filter rules like "host
192.168.1.1" cannot really be optimized - the unavoidable code path is the
"problem".
Hagen
^ permalink raw reply
* Re: [PATCH] net: batman-adv: remove rx_csum ethtool_ops
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
lindner_marek-LWAfsSFWpa4, siwu-MaAgPAbsBIVS8oHt8HbXEIQuADTiUCJX
In-Reply-To: <20110419104320.0675D1389B-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
From: Michał Mirosław <mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
Date: Tue, 19 Apr 2011 12:43:20 +0200 (CEST)
> Signed-off-by: Michał Mirosław <mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
Applied.
^ permalink raw reply
* Re: [PATCH v2] net: xen-netback: convert to hw_features
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: Ian.Campbell; +Cc: mirq-linux, netdev, xen-devel
In-Reply-To: <1303286338.5997.243.camel@zakaz.uk.xensource.com>
From: Ian Campbell <Ian.Campbell@eu.citrix.com>
Date: Wed, 20 Apr 2011 08:58:58 +0100
> On Tue, 2011-04-19 at 14:39 +0100, Michał Mirosław wrote:
>> On Tue, Apr 19, 2011 at 03:35:06PM +0200, Michał Mirosław wrote:
>> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>> > Acked-by: Ian Campbell <ian.campbell@citrix.com>
>>
>> David, I was too quick with this, so please wait with this patch until Ian
>> acks it again.
>
> Thanks Michał.
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
Applied.
^ permalink raw reply
* Re: [PATCH] net: infiniband/hw/nes: convert to hw_features
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
faisal.latif-ral2JQCrhuEAvxtiuMwx3w,
roland-DgEjT+Ai2ygdnm+yROfE0A, sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110419104320.51E5F13A64-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
From: Michał Mirosław <mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
Date: Tue, 19 Apr 2011 12:43:20 +0200 (CEST)
> Signed-off-by: Michał Mirosław <mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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: dsa: remove ethtool_ops->set_sg
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: mirq-linux; +Cc: netdev
In-Reply-To: <20110419104320.032B713909@rere.qmqm.pl>
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Tue, 19 Apr 2011 12:43:19 +0200 (CEST)
> Remove set_sg from DSA slave ethtool_ops. Features inheritance looks
> broken/not fully implemented anyway.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Applied.
^ permalink raw reply
* Re: [PATCH] net: s390: convert to hw_features
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: mirq-linux
Cc: netdev, ursula.braun, blaschka, linux390, schwidefsky,
heiko.carstens, linux-s390
In-Reply-To: <20110419104320.314AB13A66@rere.qmqm.pl>
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Tue, 19 Apr 2011 12:43:20 +0200 (CEST)
> options.large_send was easy to get rid of. options.checksum_type has deeper
> roots so is left for later cleanup.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Applied.
^ permalink raw reply
* Re: [PATCH] net: infiniband/ulp/ipoib: convert to hw_features
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: mirq-linux; +Cc: netdev, roland, sean.hefty, hal.rosenstock, linux-rdma
In-Reply-To: <20110419104320.7D01C13A67@rere.qmqm.pl>
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Tue, 19 Apr 2011 12:43:20 +0200 (CEST)
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Applied.
^ permalink raw reply
* Re: [PATCH] net: pch_gbe: convert to hw_features
From: David Miller @ 2011-04-20 8:31 UTC (permalink / raw)
To: mirq-linux; +Cc: netdev, toshiharu-linux, masa-korg
In-Reply-To: <20110419115612.C83881389B@rere.qmqm.pl>
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Tue, 19 Apr 2011 13:56:12 +0200 (CEST)
> This also fixes bug in xmit path, where TX checksum offload state was used
> instead of skb->ip_summed to decide if the offload was needed.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Applied.
^ permalink raw reply
* [RFC PATCH 1/2] net: Add multiqueue support
From: Jason Wang @ 2011-04-20 8:33 UTC (permalink / raw)
To: krkumar2, kvm, mst, netdev, rusty, qemu-devel, anthony
In-Reply-To: <20110420082706.32157.59668.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com>
This patch adds the multiqueues support for emulated nics. Each VLANClientState
pairs are now abstract as a queue instead of a nic, and multiple VLANClientState
pointers were stored in the NICState and treated as the multiple queues of a
single nic. The netdev options of qdev were now expanded to accept more than one
netdev ids. A queue_index were also introduced to let the emulated nics know
which queue the packet were came from or sent out. Virtio-net would be the first
user.
The legacy single queue nics can still run happily without modification as the
the compatibility were kept.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/qdev-properties.c | 37 ++++++++++++++++++++++++++++++-------
hw/qdev.h | 3 ++-
net.c | 34 ++++++++++++++++++++++++++--------
net.h | 15 +++++++++++----
4 files changed, 69 insertions(+), 20 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 1088a26..dd371e1 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -384,14 +384,37 @@ PropertyInfo qdev_prop_chr = {
static int parse_netdev(DeviceState *dev, Property *prop, const char *str)
{
- VLANClientState **ptr = qdev_get_prop_ptr(dev, prop);
+ VLANClientState ***nc = qdev_get_prop_ptr(dev, prop);
+ const char *ptr = str;
+ int i = 0;
+ size_t len = strlen(str);
+ *nc = qemu_malloc(MAX_QUEUE_NUM * sizeof(VLANClientState *));
+
+ while (i < MAX_QUEUE_NUM && ptr < str + len) {
+ char *name = NULL;
+ char *this = strchr(ptr, '#');
+
+ if (this == NULL) {
+ name = strdup(ptr);
+ } else {
+ name = strndup(ptr, this - ptr);
+ }
- *ptr = qemu_find_netdev(str);
- if (*ptr == NULL)
- return -ENOENT;
- if ((*ptr)->peer) {
- return -EEXIST;
+ (*nc)[i] = qemu_find_netdev(name);
+ if ((*nc)[i] == NULL) {
+ return -ENOENT;
+ }
+ if (((*nc)[i])->peer) {
+ return -EEXIST;
+ }
+
+ if (this == NULL) {
+ break;
+ }
+ i++;
+ ptr = this + 1;
}
+
return 0;
}
@@ -409,7 +432,7 @@ static int print_netdev(DeviceState *dev, Property *prop, char *dest, size_t len
PropertyInfo qdev_prop_netdev = {
.name = "netdev",
.type = PROP_TYPE_NETDEV,
- .size = sizeof(VLANClientState*),
+ .size = sizeof(VLANClientState **),
.parse = parse_netdev,
.print = print_netdev,
};
diff --git a/hw/qdev.h b/hw/qdev.h
index 8a13ec9..b438da0 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -257,6 +257,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
.defval = (bool[]) { (_defval) }, \
}
+
#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
@@ -281,7 +282,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
#define DEFINE_PROP_STRING(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
#define DEFINE_PROP_NETDEV(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
+ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState**)
#define DEFINE_PROP_VLAN(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
diff --git a/net.c b/net.c
index 4f777c3..a937e5d 100644
--- a/net.c
+++ b/net.c
@@ -227,16 +227,36 @@ NICState *qemu_new_nic(NetClientInfo *info,
{
VLANClientState *nc;
NICState *nic;
+ int i;
assert(info->type == NET_CLIENT_TYPE_NIC);
assert(info->size >= sizeof(NICState));
- nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name);
+ nc = qemu_new_net_client(info, conf->vlan, conf->peers[0], model, name);
nic = DO_UPCAST(NICState, nc, nc);
nic->conf = conf;
nic->opaque = opaque;
+ /* For compatiablity with single queue nic */
+ nic->ncs[0] = nc;
+ nc->opaque = nic;
+
+ for (i = 1 ; i < conf->queues; i++) {
+ VLANClientState *vc = qemu_mallocz(sizeof(*vc));
+ vc->opaque = nic;
+ nic->ncs[i] = vc;
+ vc->peer = conf->peers[i];
+ vc->info = info;
+ vc->queue_index = i;
+ vc->peer->peer = vc;
+ QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
+
+ vc->send_queue = qemu_new_net_queue(qemu_deliver_packet,
+ qemu_deliver_packet_iov,
+ vc);
+ }
+
return nic;
}
@@ -272,11 +292,10 @@ void qemu_del_vlan_client(VLANClientState *vc)
{
/* If there is a peer NIC, delete and cleanup client, but do not free. */
if (!vc->vlan && vc->peer && vc->peer->info->type == NET_CLIENT_TYPE_NIC) {
- NICState *nic = DO_UPCAST(NICState, nc, vc->peer);
- if (nic->peer_deleted) {
+ if (vc->peer_deleted) {
return;
}
- nic->peer_deleted = true;
+ vc->peer_deleted = true;
/* Let NIC know peer is gone. */
vc->peer->link_down = true;
if (vc->peer->info->link_status_changed) {
@@ -288,8 +307,7 @@ void qemu_del_vlan_client(VLANClientState *vc)
/* If this is a peer NIC and peer has already been deleted, free it now. */
if (!vc->vlan && vc->peer && vc->info->type == NET_CLIENT_TYPE_NIC) {
- NICState *nic = DO_UPCAST(NICState, nc, vc);
- if (nic->peer_deleted) {
+ if (vc->peer_deleted) {
qemu_free_vlan_client(vc->peer);
}
}
@@ -331,14 +349,14 @@ void qemu_foreach_nic(qemu_nic_foreach func, void *opaque)
QTAILQ_FOREACH(nc, &non_vlan_clients, next) {
if (nc->info->type == NET_CLIENT_TYPE_NIC) {
- func(DO_UPCAST(NICState, nc, nc), opaque);
+ func((NICState *)nc->opaque, opaque);
}
}
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(nc, &vlan->clients, next) {
if (nc->info->type == NET_CLIENT_TYPE_NIC) {
- func(DO_UPCAST(NICState, nc, nc), opaque);
+ func((NICState *)nc->opaque, opaque);
}
}
}
diff --git a/net.h b/net.h
index 6ceca50..c2fbd60 100644
--- a/net.h
+++ b/net.h
@@ -11,20 +11,24 @@ struct MACAddr {
uint8_t a[6];
};
+#define MAX_QUEUE_NUM 32
+
/* qdev nic properties */
typedef struct NICConf {
MACAddr macaddr;
VLANState *vlan;
- VLANClientState *peer;
+ VLANClientState **peers;
int32_t bootindex;
+ int32_t queues;
} NICConf;
#define DEFINE_NIC_PROPERTIES(_state, _conf) \
DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \
DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \
- DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \
- DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)
+ DEFINE_PROP_NETDEV("netdev", _state, _conf.peers), \
+ DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1), \
+ DEFINE_PROP_INT32("queues", _state, _conf.queues, 1)
/* VLANs support */
@@ -68,13 +72,16 @@ struct VLANClientState {
char *name;
char info_str[256];
unsigned receive_disabled : 1;
+ unsigned int queue_index;
+ bool peer_deleted;
+ void *opaque;
};
typedef struct NICState {
VLANClientState nc;
+ VLANClientState *ncs[MAX_QUEUE_NUM];
NICConf *conf;
void *opaque;
- bool peer_deleted;
} NICState;
struct VLANState {
^ permalink raw reply related
* Re: [PATCH] net: ibmveth: convert to hw_features
From: David Miller @ 2011-04-20 8:32 UTC (permalink / raw)
To: mirq-linux; +Cc: netdev, santil
In-Reply-To: <20110419121426.18A2D13909@rere.qmqm.pl>
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Tue, 19 Apr 2011 14:14:25 +0200 (CEST)
> A minimal conversion.
>
> ibmveth_set_csum_offload() can be folded into ibmveth_set_features()
> and adapter->rx_csum removed - left for later cleanup.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Applied.
^ 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