Revision 283c7c63 net.c

b/net.c
302 302
}
303 303

  
304 304
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
305
                                      VLANClientState *peer,
305 306
                                      const char *model,
306 307
                                      const char *name,
307 308
                                      NetCanReceive *can_receive,
......
326 327
    vc->opaque = opaque;
327 328

  
328 329
    if (vlan) {
330
        assert(!peer);
329 331
        vc->vlan = vlan;
330 332
        QTAILQ_INSERT_TAIL(&vc->vlan->clients, vc, next);
331 333
    } else {
334
        if (peer) {
335
            vc->peer = peer;
336
            peer->peer = vc;
337
        }
332 338
        QTAILQ_INSERT_TAIL(&non_vlan_clients, vc, next);
333 339
    }
334 340

  
......
341 347
        QTAILQ_REMOVE(&vc->vlan->clients, vc, next);
342 348
    } else {
343 349
        QTAILQ_REMOVE(&non_vlan_clients, vc, next);
350
        if (vc->peer) {
351
            vc->peer->peer = NULL;
352
        }
344 353
    }
345 354

  
346 355
    if (vc->cleanup) {
......
866 875
    }
867 876
#endif
868 877

  
869
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, slirp_receive, NULL,
878
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
879
                                 slirp_receive, NULL,
870 880
                                 net_slirp_cleanup, s);
871 881
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
872 882
             "net=%s, restricted=%c", inet_ntoa(net), restricted ? 'y' : 'n');
......
1426 1436

  
1427 1437
    s = qemu_mallocz(sizeof(TAPState));
1428 1438
    s->fd = fd;
1429
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, tap_receive,
1430
                                 tap_receive_iov, tap_cleanup, s);
1439
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
1440
                                 tap_receive, tap_receive_iov,
1441
                                 tap_cleanup, s);
1431 1442
    tap_read_poll(s, 1);
1432 1443
    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
1433 1444
    return s;
......
1760 1771
        free(s);
1761 1772
        return -1;
1762 1773
    }
1763
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_receive,
1764
                                 NULL, vde_cleanup, s);
1774
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
1775
                                 vde_receive, NULL,
1776
                                 vde_cleanup, s);
1765 1777
    qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
1766 1778
    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d",
1767 1779
             sock, vde_datafd(s->vde));
......
1999 2011
    s = qemu_mallocz(sizeof(NetSocketState));
2000 2012
    s->fd = fd;
2001 2013

  
2002
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, net_socket_receive_dgram,
2003
                                 NULL, net_socket_cleanup, s);
2014
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
2015
                                 net_socket_receive_dgram, NULL,
2016
                                 net_socket_cleanup, s);
2004 2017
    qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);
2005 2018

  
2006 2019
    /* mcast: save bound address as dst */
......
2027 2040
    NetSocketState *s;
2028 2041
    s = qemu_mallocz(sizeof(NetSocketState));
2029 2042
    s->fd = fd;
2030
    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, net_socket_receive,
2031
                                 NULL, net_socket_cleanup, s);
2043
    s->vc = qemu_new_vlan_client(vlan, NULL, model, name, NULL,
2044
                                 net_socket_receive, NULL,
2045
                                 net_socket_cleanup, s);
2032 2046
    snprintf(s->vc->info_str, sizeof(s->vc->info_str),
2033 2047
             "socket: fd=%d", fd);
2034 2048
    if (is_connected) {
......
2308 2322
        return -1;
2309 2323
    }
2310 2324

  
2311
    s->pcap_vc = qemu_new_vlan_client(vlan, device, name, NULL, dump_receive, NULL,
2325
    s->pcap_vc = qemu_new_vlan_client(vlan, NULL, device, name, NULL,
2326
                                      dump_receive, NULL,
2312 2327
                                      net_dump_cleanup, s);
2313 2328
    snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),
2314 2329
             "dump to %s (len=%d)", filename, len);

Also available in: Unified diff