Skip to contentSkip to conversation

vde-inject 0.0.0

Qemu-devel Jim C. Brown 2 participants 5 messages Feb 8, 2006 – Feb 10, 2006

lore
Share & tools
lore
#0 lore raw

I've implemented a prototype kernel module as described in this email:
http://lists.gnu.org/archive/html/qemu-devel/2005-08/msg00123.html
Full source code and makefile attached as a bz2ball.

Not really strictly related to VDE, this module basically enables the creation of a user space bridge.

Basically it creates /proc/vdeinject and uses that file to expose the netif_rx() function. When you write a packet to it, the module handles all the skb stuff and attempts to inject the packet into eth0. Currently my VDE setup seems to be broken (my vde_pcap and vde_packet in particular don't want to work with my vde_switch). It appears to work tho (as when using vde_pcap_inject to connect to tap0, a dhcpd server that I was running on tap0 was able to pick up dhcp requests from a guest).

Also, for those who want to see live updates as soon as I make changes, here is a link:

http://jma-box.student.umd.edu:8080/vde-inject/vdeinject.c

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

/* Copyright (C) 2005 Jim Brown
* Copyright (C) 2005 Henrik Nordstrom
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. *
* The VDE connection setup (open_vde) is loosely based on a similar
* functions in vdeq.c by Renzo Davoli
*/

#include <sys/socket.h>
#include <netpacket/packet.h>
#include <net/ethernet.h> /* the L2 protocols */
#include <sys/ioctl.h>
#include <fcntl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/un.h>
#include <errno.h>
#include <signal.h>

#include <linux/if_tun.h>

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>

#include <pcap.h>

#define SWITCH_MAGIC 0xfeedface
#define BUFSIZE 2048
#define ETH_ALEN 6
#define PCAP_READ_TIMEOUT 1

enum request_type {
REQ_NEW_CONTROL
};

struct request_v3 {
    uint32_t magic;
    uint32_t version;
    enum request_type type;
    struct sockaddr_un sock;
};

static int
open_vde(char *name, int intno, int group)

{
    int pid = getpid();
    struct request_v3 req;
    int fdctl;
    int fddata;
    struct sockaddr_un sock;

    if ((fdctl = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
	perror("socket");
	exit(1);
    }
    sock.sun_family = AF_UNIX;
    snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name);
    if (connect(fdctl, (struct sockaddr *) &sock, sizeof(sock))) {
	perror("connect");
	exit(1);
    }
    memset(&req, 0, sizeof(req));
    req.magic = SWITCH_MAGIC;
    req.version = 3;
    req.type = REQ_NEW_CONTROL + ((group > 0) ? ((geteuid() << 8) + group) << 8 : 0);
    req.sock.sun_family = AF_UNIX;
    sprintf(&req.sock.sun_path[1], "%5d-%2d", pid, intno);

    if ((fddata = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
	perror("socket");
	exit(1);
    }
    if (bind(fddata, (struct sockaddr *) &req.sock, sizeof(req.sock)) < 0) {
	perror("bind");
	exit(1);
    }
    if (send(fdctl, &req, sizeof(req), 0) < 0) {
	perror("send");
	exit(1);
    }
    if (recv(fdctl, &sock, sizeof(struct sockaddr_un), 0) < 0) {
	perror("recv");
	exit(1);
    }
    if (connect(fddata, (struct sockaddr *) &sock, sizeof(struct sockaddr_un)) < 0) {
	perror("connect");
	exit(1);
    }
    /* note: fdctl is intentionally leaked. Closed on exit by the OS. */
    return fddata;
}

void
set_nonblocking(int fd)

{
    int fl = fcntl(fd, F_GETFL);
    fcntl(fd, F_SETFL, (fl | O_NONBLOCK));
}

void
pcap_relay(u_char *args, const struct pcap_pkthdr *header, const u_char * packet)

{
    int * vde_socket = (int *)args;
    send(*vde_socket, packet, header->len, 0);
}

static void
wrap_dispatch(fd_set * rfd, pcap_t * handle, int vde_socket)

{
    int n;

    if (FD_ISSET(pcap_get_selectable_fd(handle), rfd)) {
	n = pcap_dispatch(handle, -1, pcap_relay, (u_char *)&vde_socket);
    }
}

int pcap_sendpacket(pcap_t * handle, const u_char * packet, int len, const char * dev) {
struct sockaddr_ll sa1;
struct ifreq ifr;

   strncpy (ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
   ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
   if (ioctl(pcap_fileno(handle), SIOCGIFINDEX, &ifr) == -1)
      return -1;

   memset(&sa1, 0, sizeof (sa1));
   sa1.sll_family = AF_PACKET;
   sa1.sll_ifindex = ifr.ifr_ifindex;
   sa1.sll_protocol = htons(ETH_P_ALL);

if (sendto(pcap_fileno(handle), packet, len, 0, (struct sockaddr *)&sa1, sizeof(sa1)) == len)

   {
	return 0;
   }
   else
   {
	return -1;

}
}

int vde_inject_fd = -1;

static void
relay(fd_set * rfd, int vde_socket, pcap_t * handle, const char * dev)

{
    int n;
    char packet[65536];
    union {
	struct sockaddr_ll ll;
	struct sockaddr_un un;
    } sa;
    socklen_t sa_len = sizeof(sa);

    if (FD_ISSET(vde_socket, rfd)) {
	n = recvfrom(vde_socket, packet, sizeof(packet), 0, (struct sockaddr *)&sa, &sa_len);
	if (n > 0)
	{
	    pcap_sendpacket(handle, packet, n, dev);
	    vde_inject_fd = open("/proc/vdeinject", O_WRONLY);
	    if (vde_inject_fd != -1)
	    {
	    	write(vde_inject_fd, packet, n);
	    	close(vde_inject_fd);
	    }
	}
	else if (n == 0)
	    exit(1);
	else if (errno != EINTR) {
	    perror("recv:");
	    exit(1);
	}
    }
}

pcap_t * a;
void handle_cl(int signal)

{       
        printf("Caught signal %d, cleaning up ...\n", signal);
        pcap_close(a);
        exit(0);
}

int
main(int argc, char **argv)

{
    int vde_socket;
    pcap_t * handle;
    char errbuf[PCAP_ERRBUF_SIZE];
    const u_char * packet;
    fd_set rfd;
    int fds;

    if (argc != 3) {
	printf("Usage: %s interface vde_socket\n", argv[0]);
	exit(1);
    }
    handle = pcap_open_live(argv[1], BUFSIZ, 1, PCAP_READ_TIMEOUT, errbuf);
    if (handle == NULL)
    {
    	printf("%s\n", errbuf);
	exit(1);
    }
    vde_socket = open_vde(argv[2], 0, 0);
    set_nonblocking(vde_socket);

    a = handle;
    signal(SIGINT, handle_cl);

    fds = pcap_get_selectable_fd(handle);
    if (vde_socket > fds)
	fds = vde_socket;
    fds += 1;
    FD_ZERO(&rfd);
    int i;
    for (;;) {
	int n;
	FD_SET(pcap_get_selectable_fd(handle), &rfd);
	FD_SET(vde_socket, &rfd);

	n = select(fds, &rfd, NULL, NULL, NULL);
	if (n > 0) {
	    wrap_dispatch(&rfd, handle, vde_socket);
	    relay(&rfd, vde_socket, handle, argv[1]);
	} else if (n < 0 && errno != EINTR) {
	    perror("select:");
	}
    }
}
#1 lore raw

Re: [Qemu-devel] vde-inject 0.0.1

Ok, I managed to fix my VDE issues and get this to work on eth0. Working sources for vde-inject and vde_pcap_inject attached.

It will cause duplicate packets to occur, but otherwise appears stable.

You need libpcap installed. (According to my pcap.h, I have pcap 2.4 installed.)

Compile vde_pcap_inject with this command:

gcc -o vde_pcap_inject vde_pcap_inject.c -lpcap

Extract the bz2ball, cd into vde-inject and type 'make'. This will build the module, which you can load via 'insmod vdeinject.ko'

Then load up the VDE network as so (running as root):

vde_switch -hub -daemon
chmod 666 /tmp/vde.ctl
./vde_pcap_inject eth0 /tmp/vde.ctl

This step will connect the VDE to eth0, creating a vmware like bridge.

You can now just run qemu apps with vdeq/vdeqemu normally, and they'll appear to be running on your LAN.

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

/* Copyright (C) 2005-2006 Jim Brown
* Copyright (C) 2005 Henrik Nordstrom
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. *
* The VDE connection setup (open_vde) is loosely based on a similar
* functions in vdeq.c by Renzo Davoli
*/

#include <sys/socket.h>
#include <netpacket/packet.h>
#include <net/ethernet.h> /* the L2 protocols */
#include <sys/ioctl.h>
#include <fcntl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/un.h>
#include <errno.h>
#include <signal.h>

#include <linux/if_tun.h>

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>

#include <pcap.h>

#define SWITCH_MAGIC 0xfeedface
#define BUFSIZE 2048
#define ETH_ALEN 6
#define PCAP_READ_TIMEOUT 1

enum request_type {
REQ_NEW_CONTROL
};

struct request_v3 {
    uint32_t magic;
    uint32_t version;
    enum request_type type;
    struct sockaddr_un sock;
};

static int
open_vde(char *name, int intno, int group)

{
    int pid = getpid();
    struct request_v3 req;
    int fdctl;
    int fddata;
    struct sockaddr_un sock;

    if ((fdctl = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
	perror("socket");
	exit(1);
    }
    sock.sun_family = AF_UNIX;
    snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name);
    if (connect(fdctl, (struct sockaddr *) &sock, sizeof(sock))) {
	perror("connect");
	exit(1);
    }
    memset(&req, 0, sizeof(req));
    req.magic = SWITCH_MAGIC;
    req.version = 3;
    // req.type = REQ_NEW_CONTROL + ((group > 0) ? ((geteuid() << 8) + group) << 8 : 0);
    // req.type = REQ_NEW_CONTROL + (port << 8);
    req.type = REQ_NEW_CONTROL + (10 << 8);
    req.sock.sun_family = AF_UNIX;
    sprintf(&req.sock.sun_path[1], "%5d-%2d", pid, intno);

    if ((fddata = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
	perror("socket");
	exit(1);
    }
    if (bind(fddata, (struct sockaddr *) &req.sock, sizeof(req.sock)) < 0) {
	perror("bind");
	exit(1);
    }
    if (send(fdctl, &req, sizeof(req), 0) < 0) {
	perror("send");
	exit(1);
    }
    if (recv(fdctl, &sock, sizeof(struct sockaddr_un), 0) < 0) {
	perror("recv");
	exit(1);
    }
    if (connect(fddata, (struct sockaddr *) &sock, sizeof(struct sockaddr_un)) < 0) {
	perror("connect");
	exit(1);
    }
    /* note: fdctl is intentionally leaked. Closed on exit by the OS. */
    return fddata;
}

void
set_nonblocking(int fd)

{
    int fl = fcntl(fd, F_GETFL);
    fcntl(fd, F_SETFL, (fl | O_NONBLOCK));
}

void
pcap_relay(u_char *args, const struct pcap_pkthdr *header, const u_char * packet)

{
    int * vde_socket = (int *)args;
    send(*vde_socket, packet, header->len, 0);
}

static void
wrap_dispatch(fd_set * rfd, pcap_t * handle, int vde_socket)

{
    int n;

    if (FD_ISSET(pcap_get_selectable_fd(handle), rfd)) {
	n = pcap_dispatch(handle, -1, pcap_relay, (u_char *)&vde_socket);
    }
}

int pcap_sendpacket(pcap_t * handle, const u_char * packet, int len, const char * dev) {
struct sockaddr_ll sa1;
struct ifreq ifr;

   strncpy (ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
   ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
   if (ioctl(pcap_fileno(handle), SIOCGIFINDEX, &ifr) == -1)
      return -1;

   memset(&sa1, 0, sizeof (sa1));
   sa1.sll_family = AF_PACKET;
   sa1.sll_ifindex = ifr.ifr_ifindex;
   sa1.sll_protocol = htons(ETH_P_ALL);

if (sendto(pcap_fileno(handle), packet, len, 0, (struct sockaddr *)&sa1, sizeof(sa1)) == len)

   {
	return 0;
   }
   else
   {
	return -1;

}
}

int vde_inject_fd = -1;

static void
relay(fd_set * rfd, int vde_socket, pcap_t * handle, const char * dev)

{
    int n;
    char packet[65536];
    union {
	struct sockaddr_ll ll;
	struct sockaddr_un un;
    } sa;
    socklen_t sa_len = sizeof(sa);

    if (FD_ISSET(vde_socket, rfd)) {
	n = recvfrom(vde_socket, packet, sizeof(packet), 0, (struct sockaddr *)&sa, &sa_len);
	if (n > 0)
	{
	    pcap_sendpacket(handle, packet, n, dev);
	    vde_inject_fd = open("/proc/vdeinject", O_WRONLY);
	    if (vde_inject_fd != -1)
	    {
	    	write(vde_inject_fd, packet, n);
	    	close(vde_inject_fd);
	    }
	}
	else if (n == 0)
	    exit(1);
	else if (errno != EINTR) {
	    perror("recv:");
	    exit(1);
	}
    }
}

pcap_t * a;
void handle_cl(int signal)

{       
        printf("Caught signal %d, cleaning up ...\n", signal);
        pcap_close(a);
        exit(0);
}

int
main(int argc, char **argv)

{
    int vde_socket;
    pcap_t * handle;
    char errbuf[PCAP_ERRBUF_SIZE];
    const u_char * packet;
    fd_set rfd;
    int fds;

    if (argc != 3) {
	printf("Usage: %s interface vde_socket\n", argv[0]);
	exit(1);
    }
    handle = pcap_open_live(argv[1], BUFSIZ, 1, PCAP_READ_TIMEOUT, errbuf);
    if (handle == NULL)
    {
    	printf("%s\n", errbuf);
	exit(1);
    }
    vde_socket = open_vde(argv[2], 0, 0);
    set_nonblocking(vde_socket);

    a = handle;
    signal(SIGINT, handle_cl);

    fds = pcap_get_selectable_fd(handle);
    if (vde_socket > fds)
	fds = vde_socket;
    fds += 1;
    FD_ZERO(&rfd);
    int i;
    for (;;) {
	int n;
	FD_SET(pcap_get_selectable_fd(handle), &rfd);
	FD_SET(vde_socket, &rfd);

	n = select(fds, &rfd, NULL, NULL, NULL);
	if (n > 0) {
	    wrap_dispatch(&rfd, handle, vde_socket);
	    relay(&rfd, vde_socket, handle, argv[1]);
	} else if (n < 0 && errno != EINTR) {
	    perror("select:");
	}
    }
}

BZh91AY&SY_���`���������������������LW�L_LM�U�\�y��@�/d��V����]��b�&eW ��jڵ���Tb(B9 S�
UAQ(��E@(QB(SL�RRD�RR)PP
BH%#�i
"�u���1�&�Bf�i���CQ� 4�&�b'��G��jm5=M�њM24�4�I�LLM�4ѧ�10& ���Ch���M�$�$�Q���z�SC�F�Ph4� ��@4h��4d�A�4��4dh2d12 4h�@I��&B`�Jl�OҘ�����d 4� �@Ѡh��@!OS�~�@CA�@ #!�"a1����S�d�7���5=GꞣFOI�4�0��@��@A�?HX��.�6���5E`�,�Ƥ l���g��
�M"������lH��I,�G���1�|���) �(�+����;���"t���������y����:��סtDXf`����ꮘ)�b�sn$�nN�b챘��%:��� �*{���<Pl��A�@R?����UI�;��]̿b֧�����H��Q �?!��c�t@C��u��G���}�3;��c���xQ�Ɂ�nN��5{� �;����|߅�������^�z�'L�x��,�‚״�:'�ϐ�K{��m��5I�@@����iB)��\�O���a���g�\���j�/_�`�o���3Ԕ׆y��i��N�.R���:FK��= Σ����DXy�Iљ�=B�����K?�b�~!G*
ʂ/ �<����aϺA�d��ʝ�Ԡ�Ԡ�[(R�6�5lie6Z�K-����dqY@}s?q���؝Aede���F?L�i�KlH�>�>�B����?��I��#�?)M#y�q�Pʅ[@i��B\B7���ZQ;�m8��qЫ6L V��i���լ�SY�73�� ��R0g�d��jm#~��mYg��>�5�Ty��M6��ĘD�*!�;�����"!칩�x� �P'c��2d�I�1�%)d;x�Xdti� -�-FXBX���� o�4�A�[wG����; 8����'(n�n�"�̅tA�E'.YE�'О�燝m��>��{3 �p�RF�O��� Զ��| ������^��ҳҰ�$g���E0 Ln)��s7��9����!b�m���TVGr������,�h�p�`h(�5��_ E�F��yeҹH�4�醶�e7s�&�"��j��A'����4��]4�BI��"b)6 ��B{?㆞f����mJMN�g��ʾ���dZ+�Q��"�Y��42ix��c�?�Gx �4�9� 0�!
�2O0�fGg�h0�~7" ""�@D��|d�7�>4<�C��;��n�W��4��< ��xA询҄ �"�.��U<�A=�D/�����Av���;�gG�XWn��6K�Z��!�߱"N
� "!�&�p=/z�~��H�B��^蕠�� 4MС�<�!��<~�6�@�{g��އ� 袠��|�6 �y�!�%㪮G��������[{E/�*�GTcת�H'� �p�Jʱ����HE���ٟ�-Ɋ���0�']�le��k/��!!N�@�΃+v�i�@��~��R-��_c�RM��֝����S�W��<��yp�\7��R��
/N��/F��J����"�*h��
��{�}&���Q��o�V5z��z�g)KL�]��XX���Z���Źg�?;���<p�֏>R1�Z�,����a�a,��4�XE��� �����?�I-L��\��� 9>�-���&g�*ݙ}T�"?$��x;��9�`��@�y�v(YCM�6c���d5��8�
�C�S����|OaֱK%E@�rggb{] �N'A0��'r�MaO�zsi�g�4�is$ڇ����w��e�\a���&����� �I#��H��M��@��+�h�ћ���=@��d���H)fQ���k�Sڡ$��^���?��Z�fE�曨�p�K �T���]��lY6K ��,�E�}�u�����$ M��q\�o��yII 3��)����y/w�| ��w|�P��>$�<
>ͫ�][��j'3�1x5dXD9O��_��{{�[�2B|���[�o����n紐�.L��֫ܡ/�]>ei3�18��8��?4?��s��m�酽���m֤sϗ��E�.�HU킧=��72����)���Ǐ-���>8�=P۲|>y�2_`ˁ�wC��;Dt����z4zw����†��$㗗!9��T�����X�hЃ��"�ܣm��YogF{0��K�C�Yn�P rde�Ocr����x�"�˺ 7g\�����~����f�`���}–�lN0H��Q#H�DA#�VH,F(,U�"0DH�(�,H���Fc� ����FADdF
1F9e@�+ YEc �dRm�m���C��f*����y���參�.=������ �R"�ƙ}Ɵs��?��[M���@�<k>�#�:�)ͧ{�!Uk�S� ǩ4� �Mj�iߍ��=�aq ��zt��ի�\M�X�+g�#a`�����h�u�Y��B�TIG�.1,��c�U6m����ژ4�Dw�Ր��6���o��
k�tH�4M�:,)�B�w�D@yv����U# �U�Uo�G� ����|�X�ДY�׽s\m�|�í�zj��i5�t�Uh�YF�`�ۛ-9���;�68��S�� �nف�!�����v���tF�Q�XM�L���p���)�x$]ϛ�e{7�;Ӊ��Na��n�V�r�lb��u���o*(�9��=Ѯ>t�h�^�� �|D?OIk��?� qsҨ�/wwR��z���Q�4���aeŬB�R��� �%��k�m5 xJ��};�#��`���&
��еma��$&!$e;��R��d������ �FIJ7VB��UӠ�H
j�
ER\Ъ]6���uLF:W@�2�ʊ�S������ݳ���̅� ������-��
%G}S~cM��� 4�6�Ҳ�^��[��5��fPZ�5��,!�e���r{�Dڻ��.�k ��rc����I�l:<oK�dl ��*�B��h�C�QIF���7��`0jB1T *�2�^˹V���+�����h�Ҍ�4f�:nd�da1>��ҏr��s4vev��EU�
��)�É:�A4�ݛ�6q�u�Q� i噚t����MTg���Eb�<8qq��ڮjp�UXcu���y���^`��hÜ'J���*K��K��70Hh�(fDdAӥTpF( Ma��m�:x �hC:�
�:�*��c��D�Յ�-���ahґd�)���p�Ys��Y��V���G�l�%f�M( �7UT�)�" iP�ݥ�������_����p&!E� R�&�X� 1������cr2�ky���� ΂`4��:�Dڷ�5�C��V�k�0�n����fq�(��v�;\ ��wź��M���,����
J� _+J�c7� �m�ݩkJ��]�AͰ%�f�y�]���~,�{qZIz4*��07 .�ڷ-)�m��8ET}�.�~{�;���.3�X{BM����l� qQ�w�:Ly���Z��06��.f�y�W�"ak��)"Zp���ɩ�;��H�{U����¸Ƹ��֎e�88l^�ּx�'G�,�2GM�v@��ؿ��Z̦��7��m���4��Y�x�Rل�f<���,,j见]j�to]���K`�c=7)�׎��������"
z��ְ��ȝ���?L��Ǔ���U~k�BBr�!��Pg�d
�����Ȅ�e�9��^�>c���-2�q%s�'.�>bmw K�ӥ��b�h�D~��DR N��έ|�/b������˘$$.ϸ1��k�P��8���t ��� C5D��X�ջcX�l
(LIJ��Ҏ��L�/�a�m$e\7,F�~3��,Y�ۃ>g3�Bb���Y��$2��/�n>���i~[8��Hgn1�fη�귙kr����zhS,UcOT���Jkj��i<m}�y��z^%�|6��̌�ϼS,�__c8�"/_m�x�������8=M�.��7�g�� x\'�{:[ �ND�G�<�W_�W�g?���a���B�80L�J���M��f�!\�a'�t0y ;|�H�].o�(JF��A8��@ئ!AȨ�_����\,��pJ�YX�����;a�B"�Yܑ�iD�2|1��;21�E��UU H�b_�����O�4��Vo�\%*R��)�ʆ��E�Ռm�)�z���c�_�0>O�������P�I&m� �qR� �U��x�P�&j"iGa܊��(�9$G)QJ����#�.o33211<�Z�i�\���J�S���ex2,n:�FǨ��S!��oݑ��kZfSدa�SBӧgw��t#�:��nk�|
���]I'q̱R0,r&�*��<�(S��7T�c[������X�*p�hAs#��y�48�˝匸�/�P�w�k>�
�̶Y�Ӡ3�7�������fs*2�:��>O*p�g��a� ��F�A�i�[��o�r$� gF_�\��U��{���Pllcm��8H��& �[�E�����K��������r�*�F� �YL{8�<��!0A��E�N�|�0�" a�Z�$$-$�������µ�G��K�U\eJE�H
8(F|ab�K=$���]~����0� �c�b�j����3v�"�,�
B����c ��Zb3� �0�y" M�D6�h�0D�o褨�l�i���0�5�j3�"��nd^ 1�I2 cp�Ȋnd�K�e9͋���R�D��8�SEd�H3d(1�> \M.Iq�<0�0�(ι�D��O$���n�ʔ���Q�T�%� _�X��\�A+,�!��BR`����_ww��/��!
�����xU$i �I�?Z� R1?�Y���@��rs+�P iT�n�%��l�"OH��D�H��D6��l4QfYw��U"���4��D) ��L=�l׃��P�C0YQ� �!�|1]u� q����?�1-��>��f���Gce�g�ys��0�U� �uթHg/
��""���4������p0]�n�hV�� ��KZ��E4/X(eeݩl�zh��o�a�*�m�5�t��S띇w���[��#v���������1;���hY�Ƀ�+��`Cy� � �6��ӭ<J�(�;ŗ��m�B�#/�� w|���33 �
�F�t8��Y���!bnH�IU��<}�S��0�!��s��܅�v>yg��]-�u�k����F����(z$

!~�,i �=l��I�_hM�^j�M����jM�J6�#F�门+%17j�T~6�L50J�Hc�pԣ�I% R�lG�b�=wҒ����9|y�z�p��h�f�xO�>�Cm�W�s=EW��9���͂��Չ�(�"�uR�p�i������Kf�Ƕ�;h/@o�>{J ���<�ጼ:٠V��i��@F�n���6'�5B�E�,5R���
��86�
oPq�D,��a��P�.^!�Z����k6�R���R��Fŗ��G�� 4���+� &0g�O�c,/�A�����z�}���xzc��+�t�k�z� �����}��W���yBc�(5.�/�S��Q8^�Ԟ���To�䎗��Sҗ=�bv�<��"z�<�Rrfg�tK+��ɂ���Y�C=��+��<�D��E1���-f�*;�hQO���m���x��Jl�Y}��ރ .�``�o�A�X�4w3�&A�.�c�����2�g)�'l$1�1&��^��j�=�

���^�o�B�
���NeNH��S>c���@7��?S�f�s/�A�\Ohͬژ�G休�}�K�(�z��h�CqaC l��������~q��@?D��99�7U�]� +���L=�Àݔ|�4���c �\2*aL��J� bqe�� 0�Fi*
�Qeّ���|O4,1A��_xx&;4s�ƛo�����6 H�,|�_'U�_��"���]�c���a�]��]$'�4S��,oh�z2�l%�]��ڈ���S!���G.q���Q�}�h�ͽ��1,7)�JDǿ�g��3�V.3DQ"�֡���+�L�,<��!�xRǜ,���c;�{���c�fA��>7ءV�^�D�jH�2����a�n �>��/����Xf185�q��|:)%I���u��M�3S؇��� E�0Ӷ�fP-ls�H�G���9�3�N'���l@� �������l�NL� �KײI5�a����᪀��Pڝ�\D����)�A�S/H0��!+��l����f�"W���O�K,���,J-����)��**��:yP�pzᢐ�P��$8J�Θ�`4�g�޹�H��+�PG�>!1�=g<4p���ª�knNX;^�v!ɚ���@�A�����y�R�>���C^���%%º�����U@6$xi C
0L�u�lh����;�;�����7��*~����Y��֣#@�=H9� ��s(3Q�rъ� "K=�!k �X��I7�1�8�|5'�(L�BƐ-���i>�V٤q#�8��#(��z��֧�8�&�L�0��S�OY�Rc��\gZ��G��@mp^�����d3�ӝ�G��;�� ګD�s_��!�/m �q%�R��x�š�Ap☽̚
ZX&ސ
�+3/23�.��3B���Bx��-���BB���,�H�M6���؎�e�Ĩg&�cHmv�RDv9��%�X�v�j�jjq�L�`�i!�l�6���x��)� Z�M���縟�fpT�}$n4�RoG0)
��܍��S��Ew�������k9$���1��ܷ6y����A ��������ۥ�����fA�`6�� ��IH�E��=lS�
�M��P1j��F��J
��Ո�_�)2��hu��0'R�2�Ӥ 4�8@� ����<�8H������ �
�$� Q94Y* �nP�&�`�����AncR�g�Jb(U!!AZ ���㘺H�C��m�E��2a-��h���
2`j��
� ��C�����.�*�� �KQAj��y'0srŒ;�6K��(�֢���� �2޸��M1��$� ����mP���o����0��txH]c��1�9�P iK&���%��w�R�H���(_#E\3/=T��vbo�1i0�s�j��2��(�~�:ﬥ��q�`��(2$4j� ������Z������mh�7�a �8��G����7T
���ք4���D����Y�BB;��5��C�p]�j�:j������� ���U� f���r���'� D������v�E�f �63�B�5�K>���HHX��:{$��Ag��h���8Ȁ�O|�����a��e�n�{�zN>��_�!?4��T��)G��k�R����!�_2#��:j����$�>�q3<# 1��
�D��-l�&8���C��A�k��:x�цj�e+��aQ��g��w-�6x�߷���땺��|/ie0����}� � �/S��~eNx��CBYl3��D�/��V��_e�����8�Ǝw���aj�쀖u�� d�УaMf��V�/��T �g)tLF�E�j�ln\�Ui��d�Ķ�; d���U'kh9�n��Qz�����Zᦐ��IQ�2%rE�Eu-dQNɅ��X-#�"D�L"4�QDCm��a9t�*LF2{�����eE!wek)|DG�l=t��2����͂aЧ g5Ɖ�lc�,�����.�%9.A$;X@i�
���ɱ��R�E
�\#���W1� #a��$�"NF�XK ��,;�p�����'��P�7�HF�HI#� �7�a�ԭ�L٪��7���COaq�ލ�d%g��f;$ #����M�ܴ�((��Ae�n�O�ǚlM�2h%��BoS��Н+���T� U>u�L��0eq\��֌r�V`�[�SEq�,K%�*����^���yP���b;��XP�M�H���(^�Ցs iB�J��7��u����#���K�kK0�I:7���"�l3n} �l��M2����9�V!KmP=5c�8�o�M���;7D�ⶽ_'�X
"W�2 $�]ٛ�o@g�C�ƹF���b|�y��e�X��D-8����,�iF<\E�vL��TB�$j&T[K���B�ߕ�
�Ȧ6-nPIJ5B�Q%�Lj+�?2�. �1W� (\T�L�����s�O��~��W|��v��@��CyUr��<9g��p�α�1�#Qz���f7�,�\`y��Yc�l��(L E6��}� C�\{��A�ē5� �;W��!$O��ae��{�_ Al�ĝ;�ix'�%����*��P�� ѨX�16�~SRf��o�����|%�����1�0���'f�d��4�T*ŀ,4�LQ�pf��l�PZ�S����E~�q�K$[��Y2�^,�������&+S
y�'"x�I �P�M�)�p�< .�@��
�VW�����r�CWh�!�b@� ����^�+.M��0������{��ȡĒF'��=�mb�(�I���fd ���Bo{�2CH�d�_r0 c�r���V�>-�&P-R`����bŰV�D u7N=m�t�E�2g������$�D ٥ �,�+��F6�-�HHMG����M�d�A�M��5!�b��$K']���'�H�I"���i�ddbj a�RpQ�)I �-���# 5d���m!�NI)�Ɠ,8���
��RN�f����� ���wl3�Hnd�&���l����\�L���`b���#��G������PB^#�
�:z'�� �a��3�Ń���a�}��6WhllQ`�(q7 sHh��n^�L���dž�{�P��4�1F�.��oX�p�9��M*5��ߣ� G���}���/� R�h��R �I qȺ\ %BJ���g�V��N�� T@x*"Ա8�:&2���N�t]��X"wm!�G�������f|��dx�"F B^#I"���>����6oˮ]>Ͳg���<:V�s{7�E;[�;��.mL�m���( ��Vz�>&������I� `��˚���u�{�ʴ�TJ��U����(�U"��Db�Ub��0E��H�7�tvC�Ja����+�B��!��c$��a����K"hr���s�)��*����5H�O��tD@��i��]�+Xc�TiA�4JԺ�m��L߶;����*VL��&F@H �C�SV��!�pL���&3�Ac���l�=�'p � A"! � "��v��31,�V(� �R �� \EN+ ȑ f(=�7�P&T��Z�mb^h�o:J3dG�J{���MN�_A26�c�V
b޾q|=��n�a�lO"���R6$]�� xo�2���3;j�:�(k����sC��J�w��.���d�l%v12��1�j�4�A:I�us�r"=
��D��o��+�c[u�`�(o�{A��a+��G�D[�J< *�2���B|�X0 �X�"�)�Aa�D�ǐgf�沙q���b+*]fBb1��øt�oRP�&���8�Y,� ��P�'cp�ɖH �T �LT�� ׎��Չ�/XSC"֩�gMۑ�p�3�3�E0֜7va7���w& �1�
�w��K a�0�E��4&�� I2�$bc<�&�ŅC�{ T�"��7��*�_'2 ���A��@ڲ��6����f���� 1�Pm�lX���4@h�(�d��B�9�(��HdA�N�Z �IT�QbL,@��1d G���E�R�� P�F�62���;JP�ьc�P,b(]o��� ���i�(�q�18�L ��f]lXe�Ap$]~��~�]���Ȧ��E��fM�+I�Ytƭ1�m1��%� ����SLFI�.,p�\��a�R�*��I� j2tݛ�"%D
eU��O�/����ɲ��0 �gG<c�9�p! �HM+=�D&�,��J�m1�l�B��T��]q�Fg`�F7�k/w� �h� �x���_5��e���h�$��B�aAːQdX�'Ab�<���M�Bk��Tq(��C��?8�f�W�e
j��ĽK2�����X�r��N9��
��V��$9 H�6��ٔ6Q�V#20*����H�C4��Ր�O>mf�i�CQ��,E@��
�/ ]�����=�;֔u�G�"���&T���vN���oF�0ޛ0�hn%o�Ue{�ɫ1��ԍ}E��o�;��Ô�X�b�D:(D�9'[� 7� ���@
� G�3h�[4Ɛ�B1
��1��D!ME>���yo��B�Ũk�,%ɱ� o� e
�PDrP�[��q̔Q��� bK�Ch27�K��Kâ�>*9��L�}�u�.�H[�-�G=��e��-���G�wgj>�@8�-*�ʖ��8����&�zd���e&�
�z��lQbc
wyv�� �)�I�؛C�~�5K��^�,����A�ę�o�����b���"SFKHl�}G6�r���<8�E����#$՝X��"(��v�,Z١t"�=xtԥ�h�_J0UD�-��h����D��7k۴|����9�@���ܔeBj P�}�b�T'��q+� �r��Cg�&-`�8�-�-�03�lE)q*"�_SRԪ2Fb"�N�T
��O���X�b��I7 ���,�#,��2��v�#�h0 $�A {�A�W�����퍘�N�e� !ȊŞ5��Xs�D�&����Q�lv4'��X;�L(-��B8�K�#GĤ��� 07�Rҏ6S��1�� �&�*b[`(���Qٲb��P�Q������Q�H�$�2�b���/ �lj@O��&�:�l%p�P�W��F6;%����$�"r U�qW� ?hNV�ŠA���E@��CgR� ��dY* �#
̦9��VX^�w��sa���
k��R�b�C� ��a�9��rC�( �/)�A�[�C�
j7�#q��0c�h�_MeS�V�3 �E]WP$9��B��{��A��
���H�f��5az9�P��!q�`XlBP�1�U�'@4�wC���"" U�*��"+XY�!J��@�'/��� -��,]n9#�b�q�*�H����bKBL�J˚���d.���'���ټ;��E�(�@�Pf׃�C�J�;���m��~��\d`�_�?�M
�'R�Ih6R�Pc{L�g�k4c��YL7ؽ;7zc269�3vv�e,r��Y<5��ci�����������]C-F Paa�!�S���V�%���qT�T�J�
3�+1�vet5�00�Ҭ�,hK��3Z!{�Y�Pҳ[׋ �NL����P�E�d�F�g�V�ȿ�Ct���[S��:�vݑ<AȲ8rJ���4p;%�*nS�mɝ�×&���!�bq���M3Z3bi�,��{�� M� �h,�b��5����%2��&X�s�$`�]7�I��
Q�-P|S&*\!n1!�?z������F�P�X�O�S�$��n�4C4$��i6��g��X� ��������MQb��G� A��scm� ʡ[h���id�"�A#� G# �v���p�f1,��-��iA����-�s�rB�.�o�+�X607��\�T�:�D q�# ��it�����?�;�"��hŧ��'x�x��p�Fw�I ���6����C���U�
�%�L;�P��!B-Q/Bi$=� (�+&
�^ZJ;�AuJ��A��(T¡"�d����"*%ÔhW�(4�<�r;�T�����I/���¤+�T8��E�Y2 ���?`��Y1��f��'�P��0�vT��̡���q�q癉���IZ{K0���A��Ŝ�P��1Qpaa�،Ѩђ5N��A��8���.�N�J�h��LF�)�F�X˗�mQM$.�(i;ʢ%*�TǓ�K��ѫ�е֥�A{��`��Bc^@L��I$�D�A���ߔ�sC����Iĝ�,�,;�*@��A@Y��7��o ,[,��K8S�1#�\�ib��;��;4���w�f!�C�fh9P�aTV���#!�ax;��q�ﹾ�[V�WS
��� ��h��L�2r�b&�Lh�Z8�Z���d�@�*���f6Z��!�ٶ�p�@{�Q��55 �T�,Š� bM��c�Yg�ָ����Y�j�%� 1�#S��-�r N��Z S��N�GTt"�iܐ ��6�d%P�.Fa� "�'i��x�2Rsc�����@��6��E8 !��Ν�Wk��� ���c󀠩�#;Oq�"M�����.��5�*������CϾ /�|���l�G�L�[`��~�M��1#y��2���L������M��a,jJ�8P\Ǜ���v���+�x�>Ī$��l�!iH +$��_¹1~A[+i7P|[8s����4 ��>�K�i}���A�����2��v�$z5�4��D�#�(Ң=�y֕4�$U� (��HX�\���.
�=MJ#',��2�����܋g¿)���-~>7� ِ�Q0��#� ������Mb��4`6�P����e���4�D �ĵ�<!� -���$1���6 Br;���K��#gs;4�@���h�G_�����h���&���-:�L]�L�}a���[ŕ!(�T2�T<ȕz�5���a�4�G3�o���^&;pC���-Z�0�]\��/��x\��(� L�b�����>t�f�^�\����hm$y4� 7;�In9%A�pA����$�3R�H���N��!�껣�8A?�� ~t�C�ڟ9�xC�F)�$s����#���7c��Q$5!E;��D�$ O����@�TM���#�|([��h�I�����y$��,��qm���^
6�؛C�wĀvG�p����jK�c�t�W�\�J���#�����i攂�QC|UcbaMyda'>a�E=���Y8���B�d�O���9��
|�$�C`V��:�%�0����{c���C�=����Y�=��)��q0&�BO����$�?p��h$�p��h�rE8P�_���

#2 lore raw

Re: Re: [Qemu-devel] vde-inject 0.0.1

Dear Jim...

Quoted 2 lines

Ok, I managed to fix my VDE issues and get this to work on eth0. Working sources for vde-inject and vde_pcap_inject attached.

I haven't tested, so I will just give "untested" comment :) Great work Jim, finally you can work on it and release the code to the public

My first note: please get rid those .o, mod.o and etc :) You just need to ship out the C file, Makefile and GPL statement :)

Second, I attach a patch (in gzipped) that adds:
- parameter to define the target network device to be used (as you wish :) )
- changing 0 to -1 when it can't create /proc entry or getting device structure
- "clean" target on Makefile

regards

Mulyadi

#3 lore raw

Re: [Qemu-devel] vde-inject 0.0.1

In reply to Jim C. Brown

Hi Jim

It's me again. here I send you another patch for the vde_pcap_inject.c. Nothing fancy here, I only did:
- move out "open" and "close" from relay() and put them on main() before entering for() loop. IMHO, this will make file operation a bit faster

- I use __builtin_expect magic to optimize the "if" condition before writing to /proc/vdeinject. here, inside relay() we assume that vdeinject is likely exist.

PS: I can't check it thoroughly since my libpcap version (0.7.2, default on Redhat 9. Yes I know it is old) doesn't have pcap_get_selectable_fd(), so I can't compile it.

regards

Mulyadi

#4 lore raw

Re: [Qemu-devel] vde-inject 0.0.1

Quoted 8 lines · Mulyadi Santosa

Hi Jim

It's me again. here I send you another patch for the vde_pcap_inject.c. Nothing fancy here, I only did:

- move out "open" and "close" from relay() and put them on main() before entering for() loop. IMHO, this will make file operation a bit faster

This one I've thought about myself.

Your way makes vde_pcap_inject more efficient. My way makes it usable if vde_pcap_inject is run before the kernel module is loaded.

The idea is that vde_pcap_inject can be used everywhere vde_pcap can be, but in addition if you have vde-inject then it can and will make use of that as well.

Quoted 5 lines

- I use __builtin_expect magic to optimize the "if" condition before writing to /proc/vdeinject. here, inside relay() we assume that vdeinject is likely exist.

What is __buiultin_expect() ? I've never seen it before.

Your tests to make sure the fd is valid are unnecessary. perror() causes vde_pcap_inject to abort with an error, so any code called later on is guarranteed that fd is valid.

Of course this means that vde_pcap_inject can only be used in combo with vde-inject, which I'm not sure is a good thing. E.g. a freeBSD host lacks vde-inject, so this would make vde_pcap_inject linux-specific.

Quoted 4 lines

PS: I can't check it thoroughly since my libpcap version (0.7.2, default on Redhat 9. Yes I know it is old) doesn't have pcap_get_selectable_fd(), so I can't compile it.

Change it to pcap_fileno(), and it should compile and work identically. (The difference is that pcap_get_selectable_fd() adds some basic sanity checks to make sure the fd is selectable before returning it. See
http://www.tcpdump.org/lists/workers/2004/06/msg00093.html for more information.)

I'll probably add an #ifdef for this.

Quoted 3 lines

regards

Mulyadi

Signature · 2 lines
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.