~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/drivers/daemon_kern.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
  4  * James Leu (jleu@mindspring.net).
  5  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  6  * Copyright (C) 2001 by various other people who didn't put their name here.
  7  */
  8 
  9 #include <linux/init.h>
 10 #include <linux/netdevice.h>
 11 #include <net_kern.h>
 12 #include "daemon.h"
 13 
 14 struct daemon_init {
 15         char *sock_type;
 16         char *ctl_sock;
 17 };
 18 
 19 static void daemon_init(struct net_device *dev, void *data)
 20 {
 21         struct uml_net_private *pri;
 22         struct daemon_data *dpri;
 23         struct daemon_init *init = data;
 24 
 25         pri = netdev_priv(dev);
 26         dpri = (struct daemon_data *) pri->user;
 27         dpri->sock_type = init->sock_type;
 28         dpri->ctl_sock = init->ctl_sock;
 29         dpri->fd = -1;
 30         dpri->control = -1;
 31         dpri->dev = dev;
 32         /* We will free this pointer. If it contains crap we're burned. */
 33         dpri->ctl_addr = NULL;
 34         dpri->data_addr = NULL;
 35         dpri->local_addr = NULL;
 36 
 37         printk("daemon backend (uml_switch version %d) - %s:%s",
 38                SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock);
 39         printk("\n");
 40 }
 41 
 42 static int daemon_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 43 {
 44         return net_recvfrom(fd, skb_mac_header(skb),
 45                             skb->dev->mtu + ETH_HEADER_OTHER);
 46 }
 47 
 48 static int daemon_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 49 {
 50         return daemon_user_write(fd, skb->data, skb->len,
 51                                  (struct daemon_data *) &lp->user);
 52 }
 53 
 54 static const struct net_kern_info daemon_kern_info = {
 55         .init                   = daemon_init,
 56         .protocol               = eth_protocol,
 57         .read                   = daemon_read,
 58         .write                  = daemon_write,
 59 };
 60 
 61 static int daemon_setup(char *str, char **mac_out, void *data)
 62 {
 63         struct daemon_init *init = data;
 64         char *remain;
 65 
 66         *init = ((struct daemon_init)
 67                 { .sock_type            = "unix",
 68                   .ctl_sock             = CONFIG_UML_NET_DAEMON_DEFAULT_SOCK });
 69 
 70         remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock,
 71                                NULL);
 72         if (remain != NULL)
 73                 printk(KERN_WARNING "daemon_setup : Ignoring data socket "
 74                        "specification\n");
 75 
 76         return 1;
 77 }
 78 
 79 static struct transport daemon_transport = {
 80         .list           = LIST_HEAD_INIT(daemon_transport.list),
 81         .name           = "daemon",
 82         .setup          = daemon_setup,
 83         .user           = &daemon_user_info,
 84         .kern           = &daemon_kern_info,
 85         .private_size   = sizeof(struct daemon_data),
 86         .setup_size     = sizeof(struct daemon_init),
 87 };
 88 
 89 static int register_daemon(void)
 90 {
 91         register_transport(&daemon_transport);
 92         return 0;
 93 }
 94 
 95 late_initcall(register_daemon);
 96 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php