This pull request contains the following changes for UML:

- Use fdatasync() in ubd
 - Add a generic "fd" vector transport
 - Minor cleanups and fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQJKBAABCAA0FiEEdgfidid8lnn52cLTZvlZhesYu8EFAl7f9LgWHHJpY2hhcmRA
 c2lnbWEtc3Rhci5hdAAKCRBm+VmF6xi7wbOtD/4pLJZC/pImN606NAI2VyBq2n8A
 Y9L1ZvZSczyuhfibNGPcYcwQuQ87ykco9zLLffVIks6pzWEzleZXJhEiGXOs6Gr+
 qc6l1u/A3G1SeXLpEXzDvdIifBPhWAetBhGwJXHTs9XbmMx7wCOTPWNe1UN8R6cl
 nIgitEdAWvb3Dd717+MkbsCTCjf5glsJzhGl7tj/KMc1f0c0Fl8+1TNclDQUpjXp
 aj9/L9X07AF0Cxlhgj5Q/r8Fyi/Hs4cXynpj+H/9Kz66M09nUtvcsuhNZPGj/+YA
 s0lEpIBup9Osh6Am4oplSdKyQGupFcriFImxziTgDLZU/AXCz5IR5fNMXRm2qcro
 HaA64WKHOreJJwHTJsKPHMnBknaa0cfBZLG5K94G4pFUFx+ky1AtfcuSLvQ7D10w
 UP0LPEhQrwsRtzGagd9V2jIgCDFaEWG8yZi/A3DGIMUJ7pFNCCIFw/febPs6EXHY
 Njgkelw5TpqsBn+IN2CWaPgeyBKMf2CP7SEggbr0xsOCsuD+gxu4yMIzyEaKUQqK
 41+9N6gYd03cU/x+/Q7g4la6f/NwpLkoTvUd9viDHO/tmxK2S701kj7Gqxz9qv6x
 LlE/dFmaGF2/a3sp1WYuj2yD+VhgNZAly2+Bd9qLkn4TQ5bgK0GNbMGT2LHi9zPB
 Z2VxLU9CtXpHMkS1Dg==
 =eKrj
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml

Pull UML updates from Richard Weinberger:

 - Use fdatasync() in ubd

 - Add a generic "fd" vector transport

 - Minor cleanups and fixes

* tag 'for-linus-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml:
  um: virtio: Replace zero-length array with flexible-array
  um: Use fdatasync() when mapping the UBD FSYNC command
  um: Do not evaluate compiler's library path when cleaning
  um: Neaten vu_err macro definition
  um: Add a generic "fd" vector transport
  um: Add include: memset() and memcpy() are in <string.h>
This commit is contained in:
Linus Torvalds 2020-06-10 13:25:40 -07:00
commit 84fc461db9
5 changed files with 64 additions and 4 deletions

View File

@ -129,7 +129,7 @@ struct vector_private {
struct vector_estats estats;
struct sock_fprog *bpf;
char user[0];
char user[];
};
extern int build_transport_data(struct vector_private *vp);

View File

@ -29,6 +29,7 @@
#include <netdb.h>
#include <stdlib.h>
#include <os.h>
#include <limits.h>
#include <um_malloc.h>
#include "vector_user.h"
@ -42,6 +43,9 @@
#define TRANS_RAW "raw"
#define TRANS_RAW_LEN strlen(TRANS_RAW)
#define TRANS_FD "fd"
#define TRANS_FD_LEN strlen(TRANS_FD)
#define VNET_HDR_FAIL "could not enable vnet headers on fd %d"
#define TUN_GET_F_FAIL "tapraw: TUNGETFEATURES failed: %s"
#define L2TPV3_BIND_FAIL "l2tpv3_open : could not bind socket err=%i"
@ -347,6 +351,59 @@ unix_cleanup:
return NULL;
}
static int strtofd(const char *nptr)
{
long fd;
char *endptr;
if (nptr == NULL)
return -1;
errno = 0;
fd = strtol(nptr, &endptr, 10);
if (nptr == endptr ||
errno != 0 ||
*endptr != '\0' ||
fd < 0 ||
fd > INT_MAX) {
return -1;
}
return fd;
}
static struct vector_fds *user_init_fd_fds(struct arglist *ifspec)
{
int fd = -1;
char *fdarg = NULL;
struct vector_fds *result = NULL;
fdarg = uml_vector_fetch_arg(ifspec, "fd");
fd = strtofd(fdarg);
if (fd == -1) {
printk(UM_KERN_ERR "fd open: bad or missing fd argument");
goto fd_cleanup;
}
result = uml_kmalloc(sizeof(struct vector_fds), UM_GFP_KERNEL);
if (result == NULL) {
printk(UM_KERN_ERR "fd open: allocation failed");
goto fd_cleanup;
}
result->rx_fd = fd;
result->tx_fd = fd;
result->remote_addr_size = 0;
result->remote_addr = NULL;
return result;
fd_cleanup:
if (fd >= 0)
os_close_file(fd);
if (result != NULL)
kfree(result);
return NULL;
}
static struct vector_fds *user_init_raw_fds(struct arglist *ifspec)
{
int rxfd = -1, txfd = -1;
@ -578,6 +635,8 @@ struct vector_fds *uml_vector_user_open(
return user_init_socket_fds(parsed, ID_L2TPV3);
if (strncmp(transport, TRANS_BESS, TRANS_BESS_LEN) == 0)
return user_init_unix_fds(parsed, ID_BESS);
if (strncmp(transport, TRANS_FD, TRANS_FD_LEN) == 0)
return user_init_fd_fds(parsed);
return NULL;
}

View File

@ -78,7 +78,7 @@ struct vhost_user_config {
u32 offset;
u32 size;
u32 flags;
u8 payload[0]; /* Variable length */
u8 payload[]; /* Variable length */
} __packed;
struct vhost_user_vring_state {

View File

@ -74,7 +74,7 @@ struct virtio_uml_vq_info {
extern unsigned long long physmem_size, highmem;
#define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, __VA_ARGS__)
#define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, ##__VA_ARGS__)
/* Vhost-user protocol */

View File

@ -6,6 +6,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@ -289,7 +290,7 @@ int os_write_file(int fd, const void *buf, int len)
int os_sync_file(int fd)
{
int n = fsync(fd);
int n = fdatasync(fd);
if (n < 0)
return -errno;