forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request torvalds#383 from motomuman/pipe-netfd-network
lkl: introduce PIPE network backend for virtio device
- Loading branch information
Showing
11 changed files
with
202 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* pipe based virtual network interface feature for LKL | ||
* Copyright (c) 2017,2016 Motomu Utsumi | ||
* | ||
* Author: Motomu Utsumi <motomuman@gmail.com> | ||
* | ||
* Current implementation is linux-specific. | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <fcntl.h> | ||
|
||
#include "virtio.h" | ||
#include "virtio_net_fd.h" | ||
|
||
struct lkl_netdev *lkl_netdev_pipe_create(char *ifname, int offload) | ||
{ | ||
struct lkl_netdev *nd; | ||
int fd_rx, fd_tx; | ||
char *ifname_rx = NULL, *ifname_tx = NULL; | ||
|
||
ifname_rx = strtok(ifname, "|"); | ||
if (ifname_rx == NULL) { | ||
fprintf(stderr, "invalid ifname format: %s\n", ifname); | ||
return NULL; | ||
} | ||
|
||
ifname_tx = strtok(NULL, "|"); | ||
if (ifname_tx == NULL) { | ||
fprintf(stderr, "invalid ifname format: %s\n", ifname); | ||
return NULL; | ||
} | ||
|
||
if (strtok(NULL, "|") != NULL) { | ||
fprintf(stderr, "invalid ifname format: %s\n", ifname); | ||
return NULL; | ||
} | ||
|
||
fd_rx = open(ifname_rx, O_RDWR|O_NONBLOCK); | ||
if (fd_rx < 0) { | ||
perror("can not open ifname_rx pipe"); | ||
return NULL; | ||
} | ||
|
||
fd_tx = open(ifname_tx, O_RDWR|O_NONBLOCK); | ||
if (fd_tx < 0) { | ||
perror("can not open ifname_tx pipe"); | ||
close(fd_rx); | ||
return NULL; | ||
} | ||
|
||
nd = lkl_register_netdev_fd(fd_rx, fd_tx); | ||
if (!nd) { | ||
perror("failed to register to."); | ||
close(fd_rx); | ||
close(fd_tx); | ||
return NULL; | ||
} | ||
|
||
/* | ||
* To avoid mismatch with LKL otherside, | ||
* we always enabled vnet hdr | ||
*/ | ||
nd->has_vnet_hdr = 1; | ||
return nd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters