Commit aff598ca authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'l2tp-cleanup-checkpatch-pl-warnings'



Tom Parkin says:

====================
l2tp: cleanup checkpatch.pl warnings

l2tp hasn't been kept up to date with the static analysis checks offered
by checkpatch.pl.

This series addresses a range of minor issues which don't involve large
changes to code structure.  The changes include:

 * tweaks to use of whitespace, comment style, line breaks,
   and indentation

 * two minor modifications to code to use a function or macro suggested
   by checkpatch

v1 -> v2

 * combine related patches (patches fixing whitespace issues, patches
   addressing comment style)

 * respin the single large patchset into a multiple smaller series for
   easier review
====================

Reviewed-by: default avatarJames Chapman <jchapman@katalix.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 637989b5 efcd8c85
Loading
Loading
Loading
Loading
+36 −33
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * L2TP core.
/* L2TP core.
 *
 * Copyright (c) 2008,2009,2010 Katalix Systems Ltd
 *
@@ -94,7 +93,7 @@ struct l2tp_skb_cb {
	unsigned long		expires;
};

#define L2TP_SKB_CB(skb)	((struct l2tp_skb_cb *) &skb->cb[sizeof(struct inet_skb_parm)])
#define L2TP_SKB_CB(skb)	((struct l2tp_skb_cb *)&(skb)->cb[sizeof(struct inet_skb_parm)])

static struct workqueue_struct *l2tp_wq;

@@ -102,8 +101,10 @@ static struct workqueue_struct *l2tp_wq;
static unsigned int l2tp_net_id;
struct l2tp_net {
	struct list_head l2tp_tunnel_list;
	/* Lock for write access to l2tp_tunnel_list */
	spinlock_t l2tp_tunnel_list_lock;
	struct hlist_head l2tp_session_hlist[L2TP_HASH_SIZE_2];
	/* Lock for write access to l2tp_session_hlist */
	spinlock_t l2tp_session_hlist_lock;
};

@@ -134,7 +135,6 @@ static inline struct hlist_head *
l2tp_session_id_hash_2(struct l2tp_net *pn, u32 session_id)
{
	return &pn->l2tp_session_hlist[hash_32(session_id, L2TP_HASH_BITS_2)];

}

/* Session hash list.
@@ -679,7 +679,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
	}

	if (L2TP_SKB_CB(skb)->has_seq) {
		/* Received a packet with sequence numbers. If we're the LNS,
		/* Received a packet with sequence numbers. If we're the LAC,
		 * check if we sre sending sequence numbers and if not,
		 * configure it so.
		 */
@@ -777,6 +777,7 @@ EXPORT_SYMBOL(l2tp_recv_common);
static int l2tp_session_queue_purge(struct l2tp_session *session)
{
	struct sk_buff *skb = NULL;

	BUG_ON(!session);
	BUG_ON(session->magic != L2TP_SESSION_MAGIC);
	while ((skb = skb_dequeue(&session->reorder_q))) {
@@ -1399,7 +1400,8 @@ out:

static struct lock_class_key l2tp_socket_class;

int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg, struct l2tp_tunnel **tunnelp)
int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 peer_tunnel_id,
		       struct l2tp_tunnel_cfg *cfg, struct l2tp_tunnel **tunnelp)
{
	struct l2tp_tunnel *tunnel = NULL;
	int err;
@@ -1593,6 +1595,7 @@ void __l2tp_session_unhash(struct l2tp_session *session)
		/* For L2TPv3 we have a per-net hash: remove from there, too */
		if (tunnel->version != L2TP_HDR_VER_2) {
			struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net);

			spin_lock_bh(&pn->l2tp_session_hlist_lock);
			hlist_del_init_rcu(&session->global_hlist);
			spin_unlock_bh(&pn->l2tp_session_hlist_lock);
@@ -1603,7 +1606,7 @@ void __l2tp_session_unhash(struct l2tp_session *session)
EXPORT_SYMBOL_GPL(__l2tp_session_unhash);

/* This function is used by the netlink SESSION_DELETE command and by
   pseudowire modules.
 * pseudowire modules.
 */
int l2tp_session_delete(struct l2tp_session *session)
{
@@ -1636,11 +1639,11 @@ void l2tp_session_set_header_len(struct l2tp_session *session, int version)
		if (session->tunnel->encap == L2TP_ENCAPTYPE_UDP)
			session->hdr_len += 4;
	}

}
EXPORT_SYMBOL_GPL(l2tp_session_set_header_len);

struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg)
struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id,
					 u32 peer_session_id, struct l2tp_session_cfg *cfg)
{
	struct l2tp_session *session;

+34 −48
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * L2TP internal definitions.
/* L2TP internal definitions.
 *
 * Copyright (c) 2008,2009 Katalix Systems Ltd
 */
@@ -22,11 +21,11 @@

/* Per tunnel, session hash table size */
#define L2TP_HASH_BITS	4
#define L2TP_HASH_SIZE	(1 << L2TP_HASH_BITS)
#define L2TP_HASH_SIZE	BIT(L2TP_HASH_BITS)

/* System-wide, session hash table size */
#define L2TP_HASH_BITS_2	8
#define L2TP_HASH_SIZE_2	(1 << L2TP_HASH_BITS_2)
#define L2TP_HASH_SIZE_2	BIT(L2TP_HASH_BITS_2)

struct sk_buff;

@@ -49,32 +48,26 @@ struct l2tp_tunnel;
 */
struct l2tp_session_cfg {
	enum l2tp_pwtype	pw_type;
	unsigned int		recv_seq:1;	/* expect receive packets with
						 * sequence numbers? */
	unsigned int		send_seq:1;	/* send packets with sequence
						 * numbers? */
	unsigned int		lns_mode:1;	/* behave as LNS? LAC enables
						 * sequence numbers under
						 * control of LNS. */
	int			debug;		/* bitmask of debug message
						 * categories */
	unsigned int		recv_seq:1;	/* expect receive packets with sequence numbers? */
	unsigned int		send_seq:1;	/* send packets with sequence numbers? */
	unsigned int		lns_mode:1;	/* behave as LNS?
						 * LAC enables sequence numbers under LNS control.
						 */
	int			debug;		/* bitmask of debug message categories */
	u16			l2specific_type; /* Layer 2 specific type */
	u8			cookie[8];	/* optional cookie */
	int			cookie_len;	/* 0, 4 or 8 bytes */
	u8			peer_cookie[8];	/* peer's cookie */
	int			peer_cookie_len; /* 0, 4 or 8 bytes */
	int			reorder_timeout; /* configured reorder timeout
						  * (in jiffies) */
	int			reorder_timeout; /* configured reorder timeout (in jiffies) */
	char			*ifname;
};

struct l2tp_session {
	int			magic;		/* should be
						 * L2TP_SESSION_MAGIC */
	int			magic;		/* should be L2TP_SESSION_MAGIC */
	long			dead;

	struct l2tp_tunnel	*tunnel;	/* back pointer to tunnel
						 * context */
	struct l2tp_tunnel	*tunnel;	/* back pointer to tunnel context */
	u32			session_id;
	u32			peer_session_id;
	u8			cookie[8];
@@ -89,28 +82,24 @@ struct l2tp_session {
	u32			nr_max;		/* max NR. Depends on tunnel */
	u32			nr_window_size;	/* NR window size */
	u32			nr_oos;		/* NR of last OOS packet */
	int			nr_oos_count;	/* For OOS recovery */
	int			nr_oos_count;	/* for OOS recovery */
	int			nr_oos_count_max;
	struct hlist_node	hlist;		/* Hash list node */
	struct hlist_node	hlist;		/* hash list node */
	refcount_t		ref_count;

	char			name[32];	/* for logging */
	char			ifname[IFNAMSIZ];
	unsigned int		recv_seq:1;	/* expect receive packets with
						 * sequence numbers? */
	unsigned int		send_seq:1;	/* send packets with sequence
						 * numbers? */
	unsigned int		lns_mode:1;	/* behave as LNS? LAC enables
						 * sequence numbers under
						 * control of LNS. */
	int			debug;		/* bitmask of debug message
						 * categories */
	int			reorder_timeout; /* configured reorder timeout
						  * (in jiffies) */
	unsigned int		recv_seq:1;	/* expect receive packets with sequence numbers? */
	unsigned int		send_seq:1;	/* send packets with sequence numbers? */
	unsigned int		lns_mode:1;	/* behave as LNS?
						 * LAC enables sequence numbers under LNS control.
						 */
	int			debug;		/* bitmask of debug message categories */
	int			reorder_timeout; /* configured reorder timeout (in jiffies) */
	int			reorder_skip;	/* set if skip to next nr */
	enum l2tp_pwtype	pwtype;
	struct l2tp_stats	stats;
	struct hlist_node	global_hlist;	/* Global hash list node */
	struct hlist_node	global_hlist;	/* global hash list node */

	int (*build_header)(struct l2tp_session *session, void *buf);
	void (*recv_skb)(struct l2tp_session *session, struct sk_buff *skb, int data_len);
@@ -123,8 +112,7 @@ struct l2tp_session {
 * sessions so incoming packets can be sorted out
 */
struct l2tp_tunnel_cfg {
	int			debug;		/* bitmask of debug message
						 * categories */
	int			debug;		/* bitmask of debug message categories */
	enum l2tp_encap_type	encap;

	/* Used only for kernel-created sockets */
@@ -148,31 +136,29 @@ struct l2tp_tunnel {

	struct rcu_head rcu;
	rwlock_t		hlist_lock;	/* protect session_hlist */
	bool			acpt_newsess;	/* Indicates whether this
						 * tunnel accepts new sessions.
						 * Protected by hlist_lock.
	bool			acpt_newsess;	/* indicates whether this tunnel accepts
						 * new sessions. Protected by hlist_lock.
						 */
	struct hlist_head	session_hlist[L2TP_HASH_SIZE];
						/* hashed list of sessions,
						 * hashed by id */
						/* hashed list of sessions, hashed by id */
	u32			tunnel_id;
	u32			peer_tunnel_id;
	int			version;	/* 2=>L2TPv2, 3=>L2TPv3 */

	char			name[20];	/* for logging */
	int			debug;		/* bitmask of debug message
						 * categories */
	int			debug;		/* bitmask of debug message categories */
	enum l2tp_encap_type	encap;
	struct l2tp_stats	stats;

	struct list_head	list;		/* Keep a list of all tunnels */
	struct list_head	list;		/* list node on per-namespace list of tunnels */
	struct net		*l2tp_net;	/* the net we belong to */

	refcount_t		ref_count;
	void (*old_sk_destruct)(struct sock *);
	struct sock		*sock;		/* Parent socket */
	int			fd;		/* Parent fd, if tunnel socket
						 * was created by userspace */
	void (*old_sk_destruct)(struct sock *sk);
	struct sock		*sock;		/* parent socket */
	int			fd;		/* parent fd, if tunnel socket was created
						 * by userspace
						 */

	struct work_struct	del_work;
};
+4 −7
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * L2TP subsystem debugfs
/* L2TP subsystem debugfs
 *
 * Copyright (c) 2010 Katalix Systems Ltd
 */
@@ -63,7 +62,6 @@ static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd)
		pd->session_idx = 0;
		l2tp_dfs_next_tunnel(pd);
	}

}

static void *l2tp_dfs_seq_start(struct seq_file *m, loff_t *offs)
@@ -90,7 +88,6 @@ out:
	return pd;
}


static void *l2tp_dfs_seq_next(struct seq_file *m, void *v, loff_t *pos)
{
	(*pos)++;
@@ -202,7 +199,7 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
			seq_printf(m, "%02x%02x%02x%02x",
				   session->cookie[4], session->cookie[5],
				   session->cookie[6], session->cookie[7]);
		seq_printf(m, "\n");
		seq_puts(m, "\n");
	}
	if (session->peer_cookie_len) {
		seq_printf(m, "   peer cookie %02x%02x%02x%02x",
@@ -212,7 +209,7 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
			seq_printf(m, "%02x%02x%02x%02x",
				   session->peer_cookie[4], session->peer_cookie[5],
				   session->peer_cookie[6], session->peer_cookie[7]);
		seq_printf(m, "\n");
		seq_puts(m, "\n");
	}

	seq_printf(m, "   %hu/%hu tx %ld/%ld/%ld rx %ld/%ld/%ld\n",
+7 −12
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * L2TPv3 ethernet pseudowire driver
/* L2TPv3 ethernet pseudowire driver
 *
 * Copyright (c) 2008,2009,2010 Katalix Systems Ltd
 */
@@ -51,7 +50,6 @@ struct l2tp_eth_sess {
	struct net_device __rcu *dev;
};


static int l2tp_eth_dev_init(struct net_device *dev)
{
	eth_hw_addr_random(dev);
@@ -100,7 +98,6 @@ static void l2tp_eth_get_stats64(struct net_device *dev,
	stats->rx_bytes   = (unsigned long)atomic_long_read(&priv->rx_bytes);
	stats->rx_packets = (unsigned long)atomic_long_read(&priv->rx_packets);
	stats->rx_errors  = (unsigned long)atomic_long_read(&priv->rx_errors);

}

static const struct net_device_ops l2tp_eth_netdev_ops = {
@@ -348,13 +345,11 @@ err:
	return rc;
}


static const struct l2tp_nl_cmd_ops l2tp_eth_nl_cmd_ops = {
	.session_create	= l2tp_eth_create,
	.session_delete	= l2tp_session_delete,
};


static int __init l2tp_eth_init(void)
{
	int err = 0;
+9 −8
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * L2TPv3 IP encapsulation support
/* L2TPv3 IP encapsulation support
 *
 * Copyright (c) 2008,2009,2010 Katalix Systems Ltd
 */
@@ -375,6 +374,7 @@ static int l2tp_ip_getname(struct socket *sock, struct sockaddr *uaddr,
		lsa->l2tp_addr.s_addr = inet->inet_daddr;
	} else {
		__be32 addr = inet->inet_rcv_saddr;

		if (!addr)
			addr = inet->inet_saddr;
		lsa->l2tp_conn_id = lsk->conn_id;
@@ -422,6 +422,7 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
	/* Get and verify the address. */
	if (msg->msg_name) {
		DECLARE_SOCKADDR(struct sockaddr_l2tpip *, lip, msg->msg_name);

		rc = -EINVAL;
		if (msg->msg_namelen < sizeof(*lip))
			goto out;
Loading