FreeBSD Bugzilla – Attachment 209488 Details for
Bug 241737
cannot use the tap interface name to build a VM
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
update_code on pci_virtio_net.c
pci_virtio_net.patch (text/plain), 3.04 KB, created by
Fabien Costard
on 2019-11-27 15:33:26 UTC
(
hide
)
Description:
update_code on pci_virtio_net.c
Filename:
MIME Type:
Creator:
Fabien Costard
Created:
2019-11-27 15:33:26 UTC
Size:
3.04 KB
patch
obsolete
>Index: pci_virtio_net.c >=================================================================== >--- pci_virtio_net.c (revision 355131) >+++ pci_virtio_net.c (working copy) >@@ -60,6 +60,9 @@ > #include <pthread.h> > #include <pthread_np.h> > #include <sysexits.h> >+#include <net/if.h> >+#include <net/if_tap.h> >+#include <dirent.h> > > #include "bhyverun.h" > #include "pci_emul.h" >@@ -817,6 +820,58 @@ > } > } > >+/* this function returns the name of the device according to the name in input >+input : * char is the interface name (or alias) >+output : * char is the name present in /dev >+if interface does not exist the function return the input by default */ >+char * findDevName(char * intName) { >+ >+ /* variable implementation */ >+ int fd; >+ char * path = "/dev/"; >+ char *tbuf, *tbuf2, *devName; >+ struct ifreq myTapInfo; //use to find the tap name >+ DIR *d; >+ struct dirent *dir; >+ >+ /* variable initialisation */ >+ devName = (char*) malloc(sizeof(char*)); >+ devName = strdup(intName); >+ >+ /* Openning directory */ >+ d = opendir("/dev/"); >+ /* readding file in directory if not empty */ >+ if (d) { >+ while ((dir = readdir(d)) != NULL) { >+ /* looking for tap file and implement it on the table tbl */ >+ tbuf = (char *) malloc((strlen(dir->d_name) + 1) * sizeof(char) ); >+ strcpy(tbuf,dir->d_name); >+ if(strncmp("tap", tbuf, 3) == 0) { >+ tbuf2 = (char *) malloc(sizeof(char) * (strlen(path) + strlen(tbuf) + 1 )); >+ tbuf2 = strdup(path); >+ strcat(tbuf2, tbuf); >+ fd = open(tbuf2, O_RDONLY); // opening the device >+ ioctl(fd, TAPGIFNAME, &myTapInfo); // looking for the tap device name >+ /* If finded we break the loop */ >+ if(strcmp(myTapInfo.ifr_name,intName) == 0 || strcmp(tbuf,intName) == 0) { >+ devName = strdup(tbuf); >+ close(fd); >+ free(tbuf2); >+ free(tbuf); >+ break; >+ } >+ close(fd); >+ free(tbuf2); >+ } >+ free(tbuf); >+ } >+ /* closing directory */ >+ closedir(d); >+ } >+ free(tbuf); >+ return devName; >+} >+ > static int > pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) > { >@@ -855,8 +910,8 @@ > if (opts != NULL) { > int err; > >- devname = vtopts = strdup(opts); >- (void) strsep(&vtopts, ","); >+ vtopts = strdup(opts); >+ devname = findDevName(strsep(&vtopts,",")); > > if (vtopts != NULL) { > err = pci_vtnet_parsemac(vtopts, sc->vsc_config.mac);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 241737
:
208881
| 209488