Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd1ae0e4 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds
Browse files

uml: network formatting



Style and other non-functional changes in the UML networking code, including
	include tidying
	style violations
	copyright updates
	printks getting severities
	userspace code calling libc directly rather than using the os_*
wrappers

There's also a exit path cleanup in the pcap driver.

Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1a805219
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
/*
 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 * Licensed under the GPL
 */

#ifndef __DAEMON_H__
#define __DAEMON_H__

#include "net_user.h"

#define SWITCH_VERSION 3
@@ -23,13 +26,4 @@ extern const struct net_user_info daemon_user_info;
extern int daemon_user_write(int fd, void *buf, int len,
			     struct daemon_data *pri);

/*
 * Overrides for Emacs so that we follow Linus's tabbing style.
 * Emacs will notice this stuff at the end of the file and automatically
 * adjust the settings for this buffer only.  This must remain at the end
 * of the file.
 * ---------------------------------------------------------------------------
 * Local variables:
 * c-file-style: "linux"
 * End:
 */
#endif
+15 −16
Original line number Diff line number Diff line
/*
 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
 * James Leu (jleu@mindspring.net).
 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 * Copyright (C) 2001 by various other people who didn't put their name here.
 * Licensed under the GPL.
 */

#include "linux/kernel.h"
#include "linux/init.h"
#include "linux/netdevice.h"
#include "linux/etherdevice.h"
#include <linux/netdevice.h>
#include "net_kern.h"
#include "net_user.h"
#include "daemon.h"

struct daemon_init {
@@ -45,16 +43,17 @@ static int daemon_read(int fd, struct sk_buff **skb,
		       struct uml_net_private *lp)
{
	*skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
	if(*skb == NULL) return(-ENOMEM);
	return(net_recvfrom(fd, skb_mac_header(*skb),
			    (*skb)->dev->mtu + ETH_HEADER_OTHER));
	if (*skb == NULL)
		return -ENOMEM;
	return net_recvfrom(fd, skb_mac_header(*skb),
			    (*skb)->dev->mtu + ETH_HEADER_OTHER);
}

static int daemon_write(int fd, struct sk_buff **skb,
			struct uml_net_private *lp)
{
	return(daemon_user_write(fd, (*skb)->data, (*skb)->len, 
				 (struct daemon_data *) &lp->user));
	return daemon_user_write(fd, (*skb)->data, (*skb)->len,
				 (struct daemon_data *) &lp->user);
}

static const struct net_kern_info daemon_kern_info = {
@@ -79,7 +78,7 @@ static int daemon_setup(char *str, char **mac_out, void *data)
		printk(KERN_WARNING "daemon_setup : Ignoring data socket "
		       "specification\n");

	return(1);
	return 1;
}

static struct transport daemon_transport = {
+42 −39
Original line number Diff line number Diff line
/*
 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
 * James Leu (jleu@mindspring.net).
 * Copyright (C) 2001 by various other people who didn't put their name here.
 * Licensed under the GPL.
 */

#include <errno.h>
#include <unistd.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include "net_user.h"
#include <sys/un.h>
#include "daemon.h"
#include "kern_util.h"
#include "user.h"
#include "net_user.h"
#include "os.h"
#include "um_malloc.h"
#include "user.h"

#define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER)

@@ -37,7 +38,8 @@ static struct sockaddr_un *new_addr(void *name, int len)

	sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
	if (sun == NULL) {
		printk("new_addr: allocation of sockaddr_un failed\n");
		printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
		       "failed\n");
		return NULL;
	}
	sun->sun_family = AF_UNIX;
@@ -56,36 +58,37 @@ static int connect_to_switch(struct daemon_data *pri)
	pri->control = socket(AF_UNIX, SOCK_STREAM, 0);
	if (pri->control < 0) {
		err = -errno;
		printk("daemon_open : control socket failed, errno = %d\n", 
		       -err);
		printk(UM_KERN_ERR "daemon_open : control socket failed, "
		       "errno = %d\n", -err);
		return err;
	}

	if (connect(pri->control, (struct sockaddr *) ctl_addr,
		   sizeof(*ctl_addr)) < 0) {
		err = -errno;
		printk("daemon_open : control connect failed, errno = %d\n",
		       -err);
		printk(UM_KERN_ERR "daemon_open : control connect failed, "
		       "errno = %d\n", -err);
		goto out;
	}

	fd = socket(AF_UNIX, SOCK_DGRAM, 0);
	if (fd < 0) {
		err = -errno;
		printk("daemon_open : data socket failed, errno = %d\n",
		       -err);
		printk(UM_KERN_ERR "daemon_open : data socket failed, "
		       "errno = %d\n", -err);
		goto out;
	}
	if (bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0) {
		err = -errno;
		printk("daemon_open : data bind failed, errno = %d\n",
		       -err);
		printk(UM_KERN_ERR "daemon_open : data bind failed, "
		       "errno = %d\n", -err);
		goto out_close;
	}

	sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
	if (sun == NULL) {
		printk("new_addr: allocation of sockaddr_un failed\n");
		printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
		       "failed\n");
		err = -ENOMEM;
		goto out_close;
	}
@@ -94,18 +97,18 @@ static int connect_to_switch(struct daemon_data *pri)
	req.version = SWITCH_VERSION;
	req.type = REQ_NEW_CONTROL;
	req.sock = *local_addr;
	n = os_write_file(pri->control, &req, sizeof(req));
	n = write(pri->control, &req, sizeof(req));
	if (n != sizeof(req)) {
		printk("daemon_open : control setup request failed, err = %d\n",
		       -n);
		printk(UM_KERN_ERR "daemon_open : control setup request "
		       "failed, err = %d\n", -errno);
		err = -ENOTCONN;
		goto out_free;
	}

	n = os_read_file(pri->control, sun, sizeof(*sun));
	n = read(pri->control, sun, sizeof(*sun));
	if (n != sizeof(*sun)) {
		printk("daemon_open : read of data socket failed, err = %d\n",
		       -n);
		printk(UM_KERN_ERR "daemon_open : read of data socket failed, "
		       "err = %d\n", -errno);
		err = -ENOTCONN;
		goto out_free;
	}
@@ -116,9 +119,9 @@ static int connect_to_switch(struct daemon_data *pri)
 out_free:
	kfree(sun);
 out_close:
	os_close_file(fd);
	close(fd);
 out:
	os_close_file(pri->control);
	close(pri->control);
	return err;
}

@@ -161,9 +164,9 @@ static void daemon_remove(void *data)
{
	struct daemon_data *pri = data;

	os_close_file(pri->fd);
	close(pri->fd);
	pri->fd = -1;
	os_close_file(pri->control);
	close(pri->control);
	pri->control = -1;

	kfree(pri->data_addr);
+5 −11
Original line number Diff line number Diff line
/* 
 * Copyright (C) 2001 Jeff Dike (jdike@karaya.com)
 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 * Licensed under the GPL
 */

#ifndef __DRIVERS_MCAST_H
#define __DRIVERS_MCAST_H

#include "net_user.h"

struct mcast_data {
@@ -18,13 +21,4 @@ extern const struct net_user_info mcast_user_info;
extern int mcast_user_write(int fd, void *buf, int len, 
			    struct mcast_data *pri);

/*
 * Overrides for Emacs so that we follow Linus's tabbing style.
 * Emacs will notice this stuff at the end of the file and automatically
 * adjust the settings for this buffer only.  This must remain at the end
 * of the file.
 * ---------------------------------------------------------------------------
 * Local variables:
 * c-file-style: "linux"
 * End:
 */
#endif
+24 −31
Original line number Diff line number Diff line
/*
 * user-mode-linux networking multicast transport
 * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org>
 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 *
 * based on the existing uml-networking code, which is
 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and
@@ -10,15 +11,10 @@
 * Licensed under the GPL.
 */

#include "linux/kernel.h"
#include "linux/init.h"
#include "linux/netdevice.h"
#include "linux/etherdevice.h"
#include "linux/in.h"
#include "linux/inet.h"
#include "net_kern.h"
#include "net_user.h"
#include <linux/netdevice.h>
#include "mcast.h"
#include "net_kern.h"

struct mcast_init {
	char *addr;
@@ -39,23 +35,20 @@ static void mcast_init(struct net_device *dev, void *data)
	dpri->ttl = init->ttl;
	dpri->dev = dev;

	printk("mcast backend ");
	printk("multicast address: %s:%u, TTL:%u ",
	printk("mcast backend multicast address: %s:%u, TTL:%u\n",
	       dpri->addr, dpri->port, dpri->ttl);

	printk("\n");
}

static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp)
{
	*skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER);
	if(*skb == NULL) return(-ENOMEM);
	return(net_recvfrom(fd, skb_mac_header(*skb),
			    (*skb)->dev->mtu + ETH_HEADER_OTHER));
	if (*skb == NULL)
		return -ENOMEM;
	return net_recvfrom(fd, skb_mac_header(*skb),
			    (*skb)->dev->mtu + ETH_HEADER_OTHER);
}

static int mcast_write(int fd, struct sk_buff **skb,
			struct uml_net_private *lp)
static int mcast_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
{
	return mcast_user_write(fd, (*skb)->data, (*skb)->len,
				(struct mcast_data *) &lp->user);
@@ -84,7 +77,7 @@ int mcast_setup(char *str, char **mac_out, void *data)
	if (remain != NULL) {
		printk(KERN_ERR "mcast_setup - Extra garbage on "
		       "specification : '%s'\n", remain);
		return(0);
		return 0;
	}

	if (port_str != NULL) {
@@ -92,7 +85,7 @@ int mcast_setup(char *str, char **mac_out, void *data)
		if ((*last != '\0') || (last == port_str)) {
			printk(KERN_ERR "mcast_setup - Bad port : '%s'\n",
			       port_str);
			return(0);
			return 0;
		}
	}

@@ -101,14 +94,14 @@ int mcast_setup(char *str, char **mac_out, void *data)
		if ((*last != '\0') || (last == ttl_str)) {
			printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n",
			       ttl_str);
			return(0);
			return 0;
		}
	}

	printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr,
	       init->port, init->ttl);

	return(1);
	return 1;
}

static struct transport mcast_transport = {
Loading