diff options
Diffstat (limited to 'net/tipc')
| -rw-r--r-- | net/tipc/addr.c | 7 | ||||
| -rw-r--r-- | net/tipc/addr.h | 1 | ||||
| -rw-r--r-- | net/tipc/bearer.c | 27 | ||||
| -rw-r--r-- | net/tipc/bearer.h | 10 | ||||
| -rw-r--r-- | net/tipc/core.c | 2 | ||||
| -rw-r--r-- | net/tipc/core.h | 15 | ||||
| -rw-r--r-- | net/tipc/crypto.c | 55 | ||||
| -rw-r--r-- | net/tipc/crypto.h | 6 | ||||
| -rw-r--r-- | net/tipc/discover.c | 5 | ||||
| -rw-r--r-- | net/tipc/group.c | 3 | ||||
| -rw-r--r-- | net/tipc/group.h | 3 | ||||
| -rw-r--r-- | net/tipc/link.c | 59 | ||||
| -rw-r--r-- | net/tipc/msg.c | 29 | ||||
| -rw-r--r-- | net/tipc/name_distr.c | 48 | ||||
| -rw-r--r-- | net/tipc/name_distr.h | 2 | ||||
| -rw-r--r-- | net/tipc/name_table.c | 57 | ||||
| -rw-r--r-- | net/tipc/name_table.h | 9 | ||||
| -rw-r--r-- | net/tipc/net.c | 2 | ||||
| -rw-r--r-- | net/tipc/netlink_compat.c | 19 | ||||
| -rw-r--r-- | net/tipc/node.c | 62 | ||||
| -rw-r--r-- | net/tipc/socket.c | 221 | ||||
| -rw-r--r-- | net/tipc/socket.h | 2 | ||||
| -rw-r--r-- | net/tipc/subscr.c | 13 | ||||
| -rw-r--r-- | net/tipc/subscr.h | 16 | ||||
| -rw-r--r-- | net/tipc/topsrv.c | 6 | ||||
| -rw-r--r-- | net/tipc/trace.c | 2 | ||||
| -rw-r--r-- | net/tipc/udp_media.c | 8 | 
27 files changed, 447 insertions, 242 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index 0f1eaed1bd1b..abe29d1aa23a 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c @@ -55,12 +55,11 @@ bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)  void tipc_set_node_id(struct net *net, u8 *id)  {  	struct tipc_net *tn = tipc_net(net); -	u32 *tmp = (u32 *)id;  	memcpy(tn->node_id, id, NODE_ID_LEN);  	tipc_nodeid2string(tn->node_id_string, id); -	tn->trial_addr = tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3]; -	pr_info("Own node identity %s, cluster identity %u\n", +	tn->trial_addr = hash128to32(id); +	pr_info("Node identity %s, cluster identity %u\n",  		tipc_own_id_string(net), tn->net_id);  } @@ -76,7 +75,7 @@ void tipc_set_node_addr(struct net *net, u32 addr)  	}  	tn->trial_addr = addr;  	tn->addr_trial_end = jiffies; -	pr_info("32-bit node address hash set to %x\n", addr); +	pr_info("Node number set to %u\n", addr);  }  char *tipc_nodeid2string(char *str, u8 *id) diff --git a/net/tipc/addr.h b/net/tipc/addr.h index 31bee0ea7b3e..1a11831bef62 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h @@ -3,6 +3,7 @@   *   * Copyright (c) 2000-2006, 2018, Ericsson AB   * Copyright (c) 2004-2005, Wind River Systems + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 650414110452..a4389ef08a98 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -72,6 +72,7 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,  /**   * tipc_media_find - locates specified media object by name + * @name: name to locate   */  struct tipc_media *tipc_media_find(const char *name)  { @@ -86,6 +87,7 @@ struct tipc_media *tipc_media_find(const char *name)  /**   * media_find_id - locates specified media object by type identifier + * @type: type identifier to locate   */  static struct tipc_media *media_find_id(u8 type)  { @@ -100,6 +102,9 @@ static struct tipc_media *media_find_id(u8 type)  /**   * tipc_media_addr_printf - record media address in print buffer + * @buf: output buffer + * @len: output buffer size remaining + * @a: input media address   */  int tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)  { @@ -127,7 +132,7 @@ int tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)   * @name: ptr to bearer name string   * @name_parts: ptr to area for bearer name components (or NULL if not needed)   * - * Returns 1 if bearer name is valid, otherwise 0. + * Return: 1 if bearer name is valid, otherwise 0.   */  static int bearer_name_validate(const char *name,  				struct tipc_bearer_names *name_parts) @@ -139,10 +144,7 @@ static int bearer_name_validate(const char *name,  	u32 if_len;  	/* copy bearer name & ensure length is OK */ -	name_copy[TIPC_MAX_BEARER_NAME - 1] = 0; -	/* need above in case non-Posix strncpy() doesn't pad with nulls */ -	strncpy(name_copy, name, TIPC_MAX_BEARER_NAME); -	if (name_copy[TIPC_MAX_BEARER_NAME - 1] != 0) +	if (strscpy(name_copy, name, TIPC_MAX_BEARER_NAME) < 0)  		return 0;  	/* ensure all component parts of bearer name are present */ @@ -169,6 +171,8 @@ static int bearer_name_validate(const char *name,  /**   * tipc_bearer_find - locates bearer object with matching bearer name + * @net: the applicable net namespace + * @name: bearer name to locate   */  struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name)  { @@ -231,6 +235,11 @@ void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest)  /**   * tipc_enable_bearer - enable bearer with the given name + * @net: the applicable net namespace + * @name: bearer name to enable + * @disc_domain: bearer domain + * @prio: bearer priority + * @attr: nlattr array   */  static int tipc_enable_bearer(struct net *net, const char *name,  			      u32 disc_domain, u32 prio, @@ -345,6 +354,8 @@ rejected:  /**   * tipc_reset_bearer - Reset all links established over this bearer + * @net: the applicable net namespace + * @b: the target bearer   */  static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b)  { @@ -366,7 +377,9 @@ void tipc_bearer_put(struct tipc_bearer *b)  }  /** - * bearer_disable + * bearer_disable - disable this bearer + * @net: the applicable net namespace + * @b: the bearer to disable   *   * Note: This routine assumes caller holds RTNL lock.   */ @@ -437,6 +450,7 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,  }  /* tipc_disable_l2_media - detach TIPC bearer from an L2 interface + * @b: the target bearer   *   * Mark L2 bearer as inactive so that incoming buffers are thrown away   */ @@ -453,6 +467,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)  /**   * tipc_l2_send_msg - send a TIPC packet out over an L2 interface + * @net: the associated network namespace   * @skb: the packet to be sent   * @b: the bearer through which the packet is to be sent   * @dest: peer destination address diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index bc0023119da2..6bf4550aa1ac 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h @@ -93,7 +93,8 @@ struct tipc_bearer;   * @raw2addr: convert from raw addr format to media addr format   * @priority: default link (and bearer) priority   * @tolerance: default time (in ms) before declaring link failure - * @window: default window (in packets) before declaring link congestion + * @min_win: minimum window (in packets) before declaring link congestion + * @max_win: maximum window (in packets) before declaring link congestion   * @mtu: max packet size bearer can support for media type not dependent on   * underlying device MTU   * @type_id: TIPC media identifier @@ -138,12 +139,15 @@ struct tipc_media {   * @pt: packet type for bearer   * @rcu: rcu struct for tipc_bearer   * @priority: default link priority for bearer - * @window: default window size for bearer + * @min_win: minimum window (in packets) before declaring link congestion + * @max_win: maximum window (in packets) before declaring link congestion   * @tolerance: default link tolerance for bearer   * @domain: network domain to which links can be established   * @identity: array index of this bearer within TIPC bearer array - * @link_req: ptr to (optional) structure making periodic link setup requests + * @disc: ptr to link setup request   * @net_plane: network plane ('A' through 'H') currently associated with bearer + * @up: bearer up flag (bit 0) + * @refcnt: tipc_bearer reference counter   *   * Note: media-specific code is responsible for initialization of the fields   * indicated below when a bearer is enabled; TIPC's generic bearer code takes diff --git a/net/tipc/core.c b/net/tipc/core.c index c2ff42900b53..5cc1f0307215 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c @@ -81,8 +81,6 @@ static int __net_init tipc_init_net(struct net *net)  	if (err)  		goto out_nametbl; -	INIT_LIST_HEAD(&tn->dist_queue); -  	err = tipc_bcast_init(net);  	if (err)  		goto out_bclink; diff --git a/net/tipc/core.h b/net/tipc/core.h index 1d57a4d3b05e..03de7b213f55 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h @@ -3,6 +3,7 @@   *   * Copyright (c) 2005-2006, 2013-2018 Ericsson AB   * Copyright (c) 2005-2007, 2010-2013, Wind River Systems + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -132,9 +133,6 @@ struct tipc_net {  	spinlock_t nametbl_lock;  	struct name_table *nametbl; -	/* Name dist queue */ -	struct list_head dist_queue; -  	/* Topology subscription server */  	struct tipc_topsrv *topsrv;  	atomic_t subscription_count; @@ -213,6 +211,17 @@ static inline u32 tipc_net_hash_mixes(struct net *net, int tn_rand)  	return net_hash_mix(&init_net) ^ net_hash_mix(net) ^ tn_rand;  } +static inline u32 hash128to32(char *bytes) +{ +	__be32 *tmp = (__be32 *)bytes; +	u32 res; + +	res = ntohl(tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3]); +	if (likely(res)) +		return res; +	return  ntohl(tmp[0] | tmp[1] | tmp[2] | tmp[3]); +} +  #ifdef CONFIG_SYSCTL  int tipc_register_sysctl(void);  void tipc_unregister_sysctl(void); diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index 740ab9ae41a6..f4fca8f7f63f 100644 --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -1,5 +1,5 @@  // SPDX-License-Identifier: GPL-2.0 -/** +/*   * net/tipc/crypto.c: TIPC crypto for key handling & packet en/decryption   *   * Copyright (c) 2019, Ericsson AB @@ -51,7 +51,7 @@  #define TIPC_REKEYING_INTV_DEF	(60 * 24) /* default: 1 day */ -/** +/*   * TIPC Key ids   */  enum { @@ -63,7 +63,7 @@ enum {  	KEY_MAX = KEY_3,  }; -/** +/*   * TIPC Crypto statistics   */  enum { @@ -90,7 +90,7 @@ int sysctl_tipc_max_tfms __read_mostly = TIPC_MAX_TFMS_DEF;  /* Key exchange switch, default: on */  int sysctl_tipc_key_exchange_enabled __read_mostly = 1; -/** +/*   * struct tipc_key - TIPC keys' status indicator   *   *         7     6     5     4     3     2     1     0 @@ -123,6 +123,8 @@ struct tipc_key {  /**   * struct tipc_tfm - TIPC TFM structure to form a list of TFMs + * @tfm: cipher handle/key + * @list: linked list of TFMs   */  struct tipc_tfm {  	struct crypto_aead *tfm; @@ -138,7 +140,7 @@ struct tipc_tfm {   * @salt: the key's SALT value   * @authsize: authentication tag size (max = 16)   * @mode: crypto mode is applied to the key - * @hint[]: a hint for user key + * @hint: a hint for user key   * @rcu: struct rcu_head   * @key: the aead key   * @gen: the key's generation @@ -166,6 +168,7 @@ struct tipc_aead {  /**   * struct tipc_crypto_stats - TIPC Crypto statistics + * @stat: array of crypto statistics   */  struct tipc_crypto_stats {  	unsigned int stat[MAX_STATS]; @@ -194,6 +197,7 @@ struct tipc_crypto_stats {   * @key_master: flag indicates if master key exists   * @legacy_user: flag indicates if a peer joins w/o master key (for bwd comp.)   * @nokey: no key indication + * @flags: combined flags field   * @lock: tipc_key lock   */  struct tipc_crypto { @@ -324,6 +328,8 @@ do {									\  /**   * tipc_aead_key_validate - Validate a AEAD user key + * @ukey: pointer to user key data + * @info: netlink info pointer   */  int tipc_aead_key_validate(struct tipc_aead_key *ukey, struct genl_info *info)  { @@ -477,6 +483,7 @@ static void tipc_aead_users_set(struct tipc_aead __rcu *aead, int val)  /**   * tipc_aead_tfm_next - Move TFM entry to the next one in list and return it + * @aead: the AEAD key pointer   */  static struct crypto_aead *tipc_aead_tfm_next(struct tipc_aead *aead)  { @@ -714,9 +721,9 @@ static void *tipc_aead_mem_alloc(struct crypto_aead *tfm,   * @__dnode: TIPC dest node if "known"   *   * Return: - * 0                   : if the encryption has completed - * -EINPROGRESS/-EBUSY : if a callback will be performed - * < 0                 : the encryption has failed + * * 0                   : if the encryption has completed + * * -EINPROGRESS/-EBUSY : if a callback will be performed + * * < 0                 : the encryption has failed   */  static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb,  			     struct tipc_bearer *b, @@ -870,9 +877,9 @@ static void tipc_aead_encrypt_done(struct crypto_async_request *base, int err)   * @b: TIPC bearer where the message has been received   *   * Return: - * 0                   : if the decryption has completed - * -EINPROGRESS/-EBUSY : if a callback will be performed - * < 0                 : the decryption has failed + * * 0                   : if the decryption has completed + * * -EINPROGRESS/-EBUSY : if a callback will be performed + * * < 0                 : the decryption has failed   */  static int tipc_aead_decrypt(struct net *net, struct tipc_aead *aead,  			     struct sk_buff *skb, struct tipc_bearer *b) @@ -1001,7 +1008,7 @@ static inline int tipc_ehdr_size(struct tipc_ehdr *ehdr)   * tipc_ehdr_validate - Validate an encryption message   * @skb: the message buffer   * - * Returns "true" if this is a valid encryption message, otherwise "false" + * Return: "true" if this is a valid encryption message, otherwise "false"   */  bool tipc_ehdr_validate(struct sk_buff *skb)  { @@ -1674,12 +1681,12 @@ static inline void tipc_crypto_clone_msg(struct net *net, struct sk_buff *_skb,   * Otherwise, the skb is freed!   *   * Return: - * 0                   : the encryption has succeeded (or no encryption) - * -EINPROGRESS/-EBUSY : the encryption is ongoing, a callback will be made - * -ENOKEK             : the encryption has failed due to no key - * -EKEYREVOKED        : the encryption has failed due to key revoked - * -ENOMEM             : the encryption has failed due to no memory - * < 0                 : the encryption has failed due to other reasons + * * 0                   : the encryption has succeeded (or no encryption) + * * -EINPROGRESS/-EBUSY : the encryption is ongoing, a callback will be made + * * -ENOKEK             : the encryption has failed due to no key + * * -EKEYREVOKED        : the encryption has failed due to key revoked + * * -ENOMEM             : the encryption has failed due to no memory + * * < 0                 : the encryption has failed due to other reasons   */  int tipc_crypto_xmit(struct net *net, struct sk_buff **skb,  		     struct tipc_bearer *b, struct tipc_media_addr *dst, @@ -1799,12 +1806,12 @@ exit:   * cluster key(s) can be taken for decryption (- recursive).   *   * Return: - * 0                   : the decryption has successfully completed - * -EINPROGRESS/-EBUSY : the decryption is ongoing, a callback will be made - * -ENOKEY             : the decryption has failed due to no key - * -EBADMSG            : the decryption has failed due to bad message - * -ENOMEM             : the decryption has failed due to no memory - * < 0                 : the decryption has failed due to other reasons + * * 0                   : the decryption has successfully completed + * * -EINPROGRESS/-EBUSY : the decryption is ongoing, a callback will be made + * * -ENOKEY             : the decryption has failed due to no key + * * -EBADMSG            : the decryption has failed due to bad message + * * -ENOMEM             : the decryption has failed due to no memory + * * < 0                 : the decryption has failed due to other reasons   */  int tipc_crypto_rcv(struct net *net, struct tipc_crypto *rx,  		    struct sk_buff **skb, struct tipc_bearer *b) diff --git a/net/tipc/crypto.h b/net/tipc/crypto.h index e71193bd5e36..ce7d4cc8a9e0 100644 --- a/net/tipc/crypto.h +++ b/net/tipc/crypto.h @@ -1,5 +1,5 @@  /* SPDX-License-Identifier: GPL-2.0 */ -/** +/*   * net/tipc/crypto.h: Include file for TIPC crypto   *   * Copyright (c) 2019, Ericsson AB @@ -53,7 +53,7 @@  #define TIPC_AES_GCM_IV_SIZE		12  #define TIPC_AES_GCM_TAG_SIZE		16 -/** +/*   * TIPC crypto modes:   * - CLUSTER_KEY:   *	One single key is used for both TX & RX in all nodes in the cluster. @@ -69,7 +69,7 @@ enum {  extern int sysctl_tipc_max_tfms __read_mostly;  extern int sysctl_tipc_key_exchange_enabled __read_mostly; -/** +/*   * TIPC encryption message format:   *   *     3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 diff --git a/net/tipc/discover.c b/net/tipc/discover.c index d4ecacddb40c..5380f605b851 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c @@ -74,6 +74,7 @@ struct tipc_discoverer {  /**   * tipc_disc_init_msg - initialize a link setup message   * @net: the applicable net namespace + * @skb: buffer containing message   * @mtyp: message type (request or response)   * @b: ptr to bearer issuing message   */ @@ -341,7 +342,7 @@ exit:   * @dest: destination address for request messages   * @skb: pointer to created frame   * - * Returns 0 if successful, otherwise -errno. + * Return: 0 if successful, otherwise -errno.   */  int tipc_disc_create(struct net *net, struct tipc_bearer *b,  		     struct tipc_media_addr *dest, struct sk_buff **skb) @@ -380,7 +381,7 @@ int tipc_disc_create(struct net *net, struct tipc_bearer *b,  /**   * tipc_disc_delete - destroy object sending periodic link setup requests - * @d: ptr to link duest structure + * @d: ptr to link dest structure   */  void tipc_disc_delete(struct tipc_discoverer *d)  { diff --git a/net/tipc/group.c b/net/tipc/group.c index b1fcd2ad5ecf..3e137d8c9d2f 100644 --- a/net/tipc/group.c +++ b/net/tipc/group.c @@ -2,6 +2,7 @@   * net/tipc/group.c: TIPC group messaging code   *   * Copyright (c) 2017, Ericsson AB + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -359,7 +360,7 @@ struct tipc_nlist *tipc_group_dests(struct tipc_group *grp)  	return &grp->dests;  } -void tipc_group_self(struct tipc_group *grp, struct tipc_name_seq *seq, +void tipc_group_self(struct tipc_group *grp, struct tipc_service_range *seq,  		     int *scope)  {  	seq->type = grp->type; diff --git a/net/tipc/group.h b/net/tipc/group.h index 76b4e5a7b39d..ea4c3be64c78 100644 --- a/net/tipc/group.h +++ b/net/tipc/group.h @@ -2,6 +2,7 @@   * net/tipc/group.h: Include file for TIPC group unicast/multicast functions   *   * Copyright (c) 2017, Ericsson AB + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -50,7 +51,7 @@ void tipc_group_delete(struct net *net, struct tipc_group *grp);  void tipc_group_add_member(struct tipc_group *grp, u32 node,  			   u32 port, u32 instance);  struct tipc_nlist *tipc_group_dests(struct tipc_group *grp); -void tipc_group_self(struct tipc_group *grp, struct tipc_name_seq *seq, +void tipc_group_self(struct tipc_group *grp, struct tipc_service_range *seq,  		     int *scope);  u32 tipc_group_exclude(struct tipc_group *grp);  void tipc_group_filter_msg(struct tipc_group *grp, diff --git a/net/tipc/link.c b/net/tipc/link.c index 06b880da2a8e..115109259430 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -120,6 +120,34 @@ struct tipc_stats {   * @reasm_buf: head of partially reassembled inbound message fragments   * @bc_rcvr: marks that this is a broadcast receiver link   * @stats: collects statistics regarding link activity + * @session: session to be used by link + * @snd_nxt_state: next send seq number + * @rcv_nxt_state: next rcv seq number + * @in_session: have received ACTIVATE_MSG from peer + * @active: link is active + * @if_name: associated interface name + * @rst_cnt: link reset counter + * @drop_point: seq number for failover handling (FIXME) + * @failover_reasm_skb: saved failover msg ptr (FIXME) + * @failover_deferdq: deferred message queue for failover processing (FIXME) + * @transmq: the link's transmit queue + * @backlog: link's backlog by priority (importance) + * @snd_nxt: next sequence number to be used + * @rcv_unacked: # messages read by user, but not yet acked back to peer + * @deferdq: deferred receive queue + * @window: sliding window size for congestion handling + * @min_win: minimal send window to be used by link + * @ssthresh: slow start threshold for congestion handling + * @max_win: maximal send window to be used by link + * @cong_acks: congestion acks for congestion avoidance (FIXME) + * @checkpoint: seq number for congestion window size handling + * @reasm_tnlmsg: fragmentation/reassembly area for tunnel protocol message + * @last_gap: last gap ack blocks for bcast (FIXME) + * @last_ga: ptr to gap ack blocks + * @bc_rcvlink: the peer specific link used for broadcast reception + * @bc_sndlink: the namespace global link used for broadcast sending + * @nack_state: bcast nack state + * @bc_peer_is_up: peer has acked the bcast init msg   */  struct tipc_link {  	u32 addr; @@ -450,7 +478,6 @@ u32 tipc_link_state(struct tipc_link *l)   * @min_win: minimal send window to be used by link   * @max_win: maximal send window to be used by link   * @session: session to be used by link - * @ownnode: identity of own node   * @peer: node id of peer node   * @peer_caps: bitmap describing peer node capabilities   * @bc_sndlink: the namespace global link used for broadcast sending @@ -458,8 +485,10 @@ u32 tipc_link_state(struct tipc_link *l)   * @inputq: queue to put messages ready for delivery   * @namedq: queue to put binding table update messages ready for delivery   * @link: return value, pointer to put the created link + * @self: local unicast link id + * @peer_id: 128-bit ID of peer   * - * Returns true if link was created, otherwise false + * Return: true if link was created, otherwise false   */  bool tipc_link_create(struct net *net, char *if_name, int bearer_id,  		      int tolerance, char net_plane, u32 mtu, int priority, @@ -532,8 +561,13 @@ bool tipc_link_create(struct net *net, char *if_name, int bearer_id,   * @inputq: queue to put messages ready for delivery   * @namedq: queue to put binding table update messages ready for delivery   * @link: return value, pointer to put the created link + * @ownnode: identity of own node + * @peer: node id of peer node + * @peer_id: 128-bit ID of peer + * @peer_caps: bitmap describing peer node capabilities + * @bc_sndlink: the namespace global link used for broadcast sending   * - * Returns true if link was created, otherwise false + * Return: true if link was created, otherwise false   */  bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id,  			 int mtu, u32 min_win, u32 max_win, u16 peer_caps, @@ -788,7 +822,7 @@ static void link_profile_stats(struct tipc_link *l)   * tipc_link_too_silent - check if link is "too silent"   * @l: tipc link to be checked   * - * Returns true if the link 'silent_intv_cnt' is about to reach the + * Return: true if the link 'silent_intv_cnt' is about to reach the   * 'abort_limit' value, otherwise false   */  bool tipc_link_too_silent(struct tipc_link *l) @@ -990,13 +1024,12 @@ void tipc_link_reset(struct tipc_link *l)   * @xmitq: returned list of packets to be sent by caller   *   * Consumes the buffer chain. - * Returns 0 if success, or errno: -ELINKCONG, -EMSGSIZE or -ENOBUFS   * Messages at TIPC_SYSTEM_IMPORTANCE are always accepted + * Return: 0 if success, or errno: -ELINKCONG, -EMSGSIZE or -ENOBUFS   */  int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,  		   struct sk_buff_head *xmitq)  { -	struct tipc_msg *hdr = buf_msg(skb_peek(list));  	struct sk_buff_head *backlogq = &l->backlogq;  	struct sk_buff_head *transmq = &l->transmq;  	struct sk_buff *skb, *_skb; @@ -1004,13 +1037,18 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,  	u16 ack = l->rcv_nxt - 1;  	u16 seqno = l->snd_nxt;  	int pkt_cnt = skb_queue_len(list); -	int imp = msg_importance(hdr);  	unsigned int mss = tipc_link_mss(l);  	unsigned int cwin = l->window;  	unsigned int mtu = l->mtu; +	struct tipc_msg *hdr;  	bool new_bundle;  	int rc = 0; +	int imp; +	if (pkt_cnt <= 0) +		return 0; + +	hdr = buf_msg(skb_peek(list));  	if (unlikely(msg_size(hdr) > mtu)) {  		pr_warn("Too large msg, purging xmit list %d %d %d %d %d!\n",  			skb_queue_len(list), msg_user(hdr), @@ -1019,6 +1057,7 @@ int tipc_link_xmit(struct tipc_link *l, struct sk_buff_head *list,  		return -EMSGSIZE;  	} +	imp = msg_importance(hdr);  	/* Allow oversubscription of one data msg per source at congestion */  	if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit)) {  		if (imp == TIPC_SYSTEM_IMPORTANCE) { @@ -1260,7 +1299,7 @@ static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,  		pr_warn("Dropping received illegal msg type\n");  		kfree_skb(skb);  		return true; -	}; +	}  }  /* tipc_link_input - process packet that has passed link protocol check @@ -2376,7 +2415,7 @@ int tipc_link_bc_sync_rcv(struct tipc_link *l, struct tipc_msg *hdr,  	if (!msg_peer_node_is_up(hdr))  		return rc; -	/* Open when peer ackowledges our bcast init msg (pkt #1) */ +	/* Open when peer acknowledges our bcast init msg (pkt #1) */  	if (msg_ack(hdr))  		l->bc_peer_is_up = true; @@ -2505,7 +2544,7 @@ void tipc_link_set_queue_limits(struct tipc_link *l, u32 min_win, u32 max_win)  }  /** - * link_reset_stats - reset link statistics + * tipc_link_reset_stats - reset link statistics   * @l: pointer to link   */  void tipc_link_reset_stats(struct tipc_link *l) diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 32c79c59052b..2aca86021df5 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -58,11 +58,13 @@ static unsigned int align(unsigned int i)  /**   * tipc_buf_acquire - creates a TIPC message buffer   * @size: message size (including TIPC header) + * @gfp: memory allocation flags   * - * Returns a new buffer with data pointers set to the specified size. + * Return: a new buffer with data pointers set to the specified size.   * - * NOTE: Headroom is reserved to allow prepending of a data link header. - *       There may also be unrequested tailroom present at the buffer's end. + * NOTE: + * Headroom is reserved to allow prepending of a data link header. + * There may also be unrequested tailroom present at the buffer's end.   */  struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp)  { @@ -207,8 +209,9 @@ err:   * @m: the data to be appended   * @mss: max allowable size of buffer   * @dlen: size of data to be appended - * @txq: queue to appand to - * Returns the number og 1k blocks appended or errno value + * @txq: queue to append to + * + * Return: the number of 1k blocks appended or errno value   */  int tipc_msg_append(struct tipc_msg *_hdr, struct msghdr *m, int dlen,  		    int mss, struct sk_buff_head *txq) @@ -312,7 +315,7 @@ bool tipc_msg_validate(struct sk_buff **_skb)   * @pktmax: max size of a fragment incl. the header   * @frags: returned fragment skb list   * - * Returns 0 if the fragmentation is successful, otherwise: -EINVAL + * Return: 0 if the fragmentation is successful, otherwise: -EINVAL   * or -ENOMEM   */  int tipc_msg_fragment(struct sk_buff *skb, const struct tipc_msg *hdr, @@ -367,6 +370,7 @@ error:   * tipc_msg_build - create buffer chain containing specified header and data   * @mhdr: Message header, to be prepended to data   * @m: User message + * @offset: buffer offset for fragmented messages (FIXME)   * @dsz: Total length of user data   * @pktmax: Max packet size that can be used   * @list: Buffer or chain of buffers to be returned to caller @@ -374,7 +378,7 @@ error:   * Note that the recursive call we are making here is safe, since it can   * logically go only one further level down.   * - * Returns message data size or errno: -ENOMEM, -EFAULT + * Return: message data size or errno: -ENOMEM, -EFAULT   */  int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, int offset,  		   int dsz, int pktmax, struct sk_buff_head *list) @@ -485,7 +489,7 @@ error:   * @msg: message to be appended   * @max: max allowable size for the bundle buffer   * - * Returns "true" if bundling has been performed, otherwise "false" + * Return: "true" if bundling has been performed, otherwise "false"   */  static bool tipc_msg_bundle(struct sk_buff *bskb, struct tipc_msg *msg,  			    u32 max) @@ -580,9 +584,9 @@ bundle:   *  @skb: buffer to be extracted from.   *  @iskb: extracted inner buffer, to be returned   *  @pos: position in outer message of msg to be extracted. - *        Returns position of next msg + *  Returns position of next msg.   *  Consumes outer buffer when last packet extracted - *  Returns true when there is an extracted buffer, otherwise false + *  Return: true when there is an extracted buffer, otherwise false   */  bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos)  { @@ -626,7 +630,7 @@ none:   * @skb:  buffer containing message to be reversed; will be consumed   * @err:  error code to be set in message, if any   * Replaces consumed buffer with new one when successful - * Returns true if success, otherwise false + * Return: true if success, otherwise false   */  bool tipc_msg_reverse(u32 own_node,  struct sk_buff **skb, int err)  { @@ -698,10 +702,11 @@ bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy)  /**   * tipc_msg_lookup_dest(): try to find new destination for named message + * @net: pointer to associated network namespace   * @skb: the buffer containing the message.   * @err: error code to be used by caller if lookup fails   * Does not consume buffer - * Returns true if a destination is found, false otherwise + * Return: true if a destination is found, false otherwise   */  bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)  { diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index fe4edce459ad..6cf57c3bfa27 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c @@ -50,6 +50,8 @@ struct distr_queue_item {  /**   * publ_to_item - add publication info to a publication message + * @p: publication info + * @i: location of item in the message   */  static void publ_to_item(struct distr_item *i, struct publication *p)  { @@ -62,6 +64,10 @@ static void publ_to_item(struct distr_item *i, struct publication *p)  /**   * named_prepare_buf - allocate & initialize a publication message + * @net: the associated network namespace + * @type: message type + * @size: payload size + * @dest: destination node   *   * The buffer returned is of size INT_H_SIZE + payload size   */ @@ -83,6 +89,8 @@ static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,  /**   * tipc_named_publish - tell other nodes about a new publication by this node + * @net: the associated network namespace + * @publ: the new publication   */  struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ)  { @@ -111,6 +119,8 @@ struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ)  /**   * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node + * @net: the associated network namespace + * @publ: the withdrawn publication   */  struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ)  { @@ -138,9 +148,11 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ)  /**   * named_distribute - prepare name info for bulk distribution to another node + * @net: the associated network namespace   * @list: list of messages (buffers) to be returned from this function   * @dnode: node to be updated   * @pls: linked list of publication items to be packed into buffer chain + * @seqno: sequence number for this message   */  static void named_distribute(struct net *net, struct sk_buff_head *list,  			     u32 dnode, struct list_head *pls, u16 seqno) @@ -194,6 +206,9 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,  /**   * tipc_named_node_up - tell specified node about all publications by this node + * @net: the associated network namespace + * @dnode: destination node + * @capabilities: peer node's capabilities   */  void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)  { @@ -217,6 +232,9 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)  /**   * tipc_publ_purge - remove publication associated with a failed node + * @net: the associated network namespace + * @publ: the publication to remove + * @addr: failed node's address   *   * Invoked for each publication issued by a newly failed node.   * Removes publication structure from name table & deletes it. @@ -244,24 +262,6 @@ static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr)  		kfree_rcu(p, rcu);  } -/** - * tipc_dist_queue_purge - remove deferred updates from a node that went down - */ -static void tipc_dist_queue_purge(struct net *net, u32 addr) -{ -	struct tipc_net *tn = net_generic(net, tipc_net_id); -	struct distr_queue_item *e, *tmp; - -	spin_lock_bh(&tn->nametbl_lock); -	list_for_each_entry_safe(e, tmp, &tn->dist_queue, next) { -		if (e->node != addr) -			continue; -		list_del(&e->next); -		kfree(e); -	} -	spin_unlock_bh(&tn->nametbl_lock); -} -  void tipc_publ_notify(struct net *net, struct list_head *nsub_list,  		      u32 addr, u16 capabilities)  { @@ -272,7 +272,6 @@ void tipc_publ_notify(struct net *net, struct list_head *nsub_list,  	list_for_each_entry_safe(publ, tmp, nsub_list, binding_node)  		tipc_publ_purge(net, publ, addr); -	tipc_dist_queue_purge(net, addr);  	spin_lock_bh(&tn->nametbl_lock);  	if (!(capabilities & TIPC_NAMED_BCAST))  		nt->rc_dests--; @@ -282,9 +281,13 @@ void tipc_publ_notify(struct net *net, struct list_head *nsub_list,  /**   * tipc_update_nametbl - try to process a nametable update and notify   *			 subscribers + * @net: the associated network namespace + * @i: location of item in the message + * @node: node address + * @dtype: name distributor message type   *   * tipc_nametbl_lock must be held. - * Returns the publication item if successful, otherwise NULL. + * Return: the publication item if successful, otherwise NULL.   */  static bool tipc_update_nametbl(struct net *net, struct distr_item *i,  				u32 node, u32 dtype) @@ -366,6 +369,10 @@ static struct sk_buff *tipc_named_dequeue(struct sk_buff_head *namedq,  /**   * tipc_named_rcv - process name table update messages sent by another node + * @net: the associated network namespace + * @namedq: queue to receive from + * @rcv_nxt: store last received seqno here + * @open: last bulk msg was received (FIXME)   */  void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq,  		    u16 *rcv_nxt, bool *open) @@ -393,6 +400,7 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq,  /**   * tipc_named_reinit - re-initialize local publications + * @net: the associated network namespace   *   * This routine is called whenever TIPC networking is enabled.   * All name table entries published by this node are updated to reflect diff --git a/net/tipc/name_distr.h b/net/tipc/name_distr.h index 092323158f06..e231e6964d61 100644 --- a/net/tipc/name_distr.h +++ b/net/tipc/name_distr.h @@ -46,7 +46,7 @@   * @type: name sequence type   * @lower: name sequence lower bound   * @upper: name sequence upper bound - * @ref: publishing port reference + * @port: publishing port reference   * @key: publication key   *   * ===> All fields are stored in network byte order. <=== diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 2ac33d32edc2..ee5ac40ea2b6 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -3,6 +3,7 @@   *   * Copyright (c) 2000-2006, 2014-2018, Ericsson AB   * Copyright (c) 2004-2008, 2010-2014, Wind River Systems + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -103,7 +104,8 @@ RB_DECLARE_CALLBACKS_MAX(static, sr_callbacks,   *                               range match   * @sr: the service range pointer as a loop cursor   * @sc: the pointer to tipc service which holds the service range rbtree - * @start, end: the range (end >= start) for matching + * @start: beginning of the search range (end >= start) for matching + * @end: end of the search range (end >= start) for matching   */  #define service_range_foreach_match(sr, sc, start, end)			\  	for (sr = service_range_match_first((sc)->ranges.rb_node,	\ @@ -117,7 +119,8 @@ RB_DECLARE_CALLBACKS_MAX(static, sr_callbacks,  /**   * service_range_match_first - find first service range matching a range   * @n: the root node of service range rbtree for searching - * @start, end: the range (end >= start) for matching + * @start: beginning of the search range (end >= start) for matching + * @end: end of the search range (end >= start) for matching   *   * Return: the leftmost service range node in the rbtree that overlaps the   * specific range if any. Otherwise, returns NULL. @@ -166,7 +169,8 @@ static struct service_range *service_range_match_first(struct rb_node *n,  /**   * service_range_match_next - find next service range matching a range   * @n: a node in service range rbtree from which the searching starts - * @start, end: the range (end >= start) for matching + * @start: beginning of the search range (end >= start) for matching + * @end: end of the search range (end >= start) for matching   *   * Return: the next service range node to the given node in the rbtree that   * overlaps the specific range if any. Otherwise, returns NULL. @@ -218,6 +222,13 @@ static int hash(int x)  /**   * tipc_publ_create - create a publication structure + * @type: name sequence type + * @lower: name sequence lower bound + * @upper: name sequence upper bound + * @scope: publication scope + * @node: network address of publishing socket + * @port: publishing port + * @key: publication key   */  static struct publication *tipc_publ_create(u32 type, u32 lower, u32 upper,  					    u32 scope, u32 node, u32 port, @@ -245,6 +256,8 @@ static struct publication *tipc_publ_create(u32 type, u32 lower, u32 upper,  /**   * tipc_service_create - create a service structure for the specified 'type' + * @type: service type + * @hd: name_table services list   *   * Allocates a single range structure and sets it to all 0's.   */ @@ -361,6 +374,9 @@ err:  /**   * tipc_service_remove_publ - remove a publication from a service + * @sr: service_range to remove publication from + * @node: target node + * @key: target publication key   */  static struct publication *tipc_service_remove_publ(struct service_range *sr,  						    u32 node, u32 key) @@ -377,7 +393,7 @@ static struct publication *tipc_service_remove_publ(struct service_range *sr,  	return NULL;  } -/** +/*   * Code reused: time_after32() for the same purpose   */  #define publication_after(pa, pb) time_after32((pa)->id, (pb)->id) @@ -395,6 +411,8 @@ static int tipc_publ_sort(void *priv, struct list_head *a,   * tipc_service_subscribe - attach a subscription, and optionally   * issue the prescribed number of events if there is any service   * range overlapping with the requested range + * @service: the tipc_service to attach the @sub to + * @sub: the subscription to attach   */  static void tipc_service_subscribe(struct tipc_service *service,  				   struct tipc_subscription *sub) @@ -403,12 +421,12 @@ static void tipc_service_subscribe(struct tipc_service *service,  	struct publication *p, *first, *tmp;  	struct list_head publ_list;  	struct service_range *sr; -	struct tipc_name_seq ns; +	struct tipc_service_range r;  	u32 filter; -	ns.type = tipc_sub_read(sb, seq.type); -	ns.lower = tipc_sub_read(sb, seq.lower); -	ns.upper = tipc_sub_read(sb, seq.upper); +	r.type = tipc_sub_read(sb, seq.type); +	r.lower = tipc_sub_read(sb, seq.lower); +	r.upper = tipc_sub_read(sb, seq.upper);  	filter = tipc_sub_read(sb, filter);  	tipc_sub_get(sub); @@ -418,7 +436,7 @@ static void tipc_service_subscribe(struct tipc_service *service,  		return;  	INIT_LIST_HEAD(&publ_list); -	service_range_foreach_match(sr, service, ns.lower, ns.upper) { +	service_range_foreach_match(sr, service, r.lower, r.upper) {  		first = NULL;  		list_for_each_entry(p, &sr->all_publ, all_publ) {  			if (filter & TIPC_SUB_PORTS) @@ -528,14 +546,16 @@ exit:  /**   * tipc_nametbl_translate - perform service instance to socket translation - * - * On entry, 'dnode' is the search domain used during translation. + * @net: network namespace + * @type: message type + * @instance: message instance + * @dnode: the search domain used during translation   *   * On exit:   * - if translation is deferred to another node, leave 'dnode' unchanged and - *   return 0 + * return 0   * - if translation is attempted and succeeds, set 'dnode' to the publishing - *   node and return the published (non-zero) port number + * node and return the published (non-zero) port number   * - if translation is attempted and fails, set 'dnode' to 0 and return 0   *   * Note that for legacy users (node configured with Z.C.N address format) the @@ -756,6 +776,11 @@ exit:  /**   * tipc_nametbl_withdraw - withdraw a service binding + * @net: network namespace + * @type: service type + * @lower: service range lower bound + * @upper: service range upper bound + * @key: target publication key   */  int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower,  			  u32 upper, u32 key) @@ -791,6 +816,7 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower,  /**   * tipc_nametbl_subscribe - add a subscription object to the name table + * @sub: subscription to add   */  bool tipc_nametbl_subscribe(struct tipc_subscription *sub)  { @@ -821,6 +847,7 @@ bool tipc_nametbl_subscribe(struct tipc_subscription *sub)  /**   * tipc_nametbl_unsubscribe - remove a subscription object from name table + * @sub: subscription to remove   */  void tipc_nametbl_unsubscribe(struct tipc_subscription *sub)  { @@ -870,7 +897,9 @@ int tipc_nametbl_init(struct net *net)  }  /** - *  tipc_service_delete - purge all publications for a service and delete it + * tipc_service_delete - purge all publications for a service and delete it + * @net: the associated network namespace + * @sc: tipc_service to delete   */  static void tipc_service_delete(struct net *net, struct tipc_service *sc)  { diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index 8064e1986e2c..5a82a01369d6 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h @@ -60,8 +60,8 @@ struct tipc_group;   * @key: publication key, unique across the cluster   * @id: publication id   * @binding_node: all publications from the same node which bound this one - * - Remote publications: in node->publ_list - *   Used by node/name distr to withdraw publications when node is lost + * - Remote publications: in node->publ_list; + * Used by node/name distr to withdraw publications when node is lost   * - Local/node scope publications: in name_table->node_scope list   * - Local/cluster scope publications: in name_table->cluster_scope list   * @binding_sock: all publications from the same socket which bound this one @@ -92,13 +92,16 @@ struct publication {  /**   * struct name_table - table containing all existing port name publications - * @seq_hlist: name sequence hash lists + * @services: name sequence hash lists   * @node_scope: all local publications with node scope   *               - used by name_distr during re-init of name table   * @cluster_scope: all local publications with cluster scope   *               - used by name_distr to send bulk updates to new nodes   *               - used by name_distr during re-init of name table + * @cluster_scope_lock: lock for accessing @cluster_scope   * @local_publ_count: number of publications issued by this node + * @rc_dests: destination node counter + * @snd_nxt: next sequence number to be used   */  struct name_table {  	struct hlist_head services[TIPC_NAMETBL_SIZE]; diff --git a/net/tipc/net.c b/net/tipc/net.c index 0bb2323201da..a129f661bee3 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c @@ -132,7 +132,7 @@ static void tipc_net_finalize(struct net *net, u32 addr)  	tipc_named_reinit(net);  	tipc_sk_reinit(net);  	tipc_mon_reinit_self(net); -	tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, +	tipc_nametbl_publish(net, TIPC_NODE_STATE, addr, addr,  			     TIPC_CLUSTER_SCOPE, 0, addr);  } diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 1c7aa51cc2a3..5a1ce64039f7 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -118,7 +118,8 @@ static void tipc_tlv_init(struct sk_buff *skb, u16 type)  	skb_put(skb, sizeof(struct tlv_desc));  } -static int tipc_tlv_sprintf(struct sk_buff *skb, const char *fmt, ...) +static __printf(2, 3) int tipc_tlv_sprintf(struct sk_buff *skb, +					   const char *fmt, ...)  {  	int n;  	u16 len; @@ -212,12 +213,14 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,  	}  	info.attrs = attrbuf; -	err = nlmsg_parse_deprecated(cb.nlh, GENL_HDRLEN, attrbuf, -				     tipc_genl_family.maxattr, -				     tipc_genl_family.policy, NULL); -	if (err) -		goto err_out; +	if (nlmsg_len(cb.nlh) > 0) { +		err = nlmsg_parse_deprecated(cb.nlh, GENL_HDRLEN, attrbuf, +					     tipc_genl_family.maxattr, +					     tipc_genl_family.policy, NULL); +		if (err) +			goto err_out; +	}  	do {  		int rem; @@ -588,7 +591,7 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,  		return 0;  	tipc_tlv_sprintf(msg->rep, "\nLink <%s>\n", -			 nla_data(link[TIPC_NLA_LINK_NAME])); +			 (char *)nla_data(link[TIPC_NLA_LINK_NAME]));  	if (link[TIPC_NLA_LINK_BROADCAST]) {  		__fill_bc_link_stat(msg, prop, stats); @@ -695,7 +698,7 @@ static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,  	link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);  	link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP])); -	nla_strlcpy(link_info.str, link[TIPC_NLA_LINK_NAME], +	nla_strscpy(link_info.str, link[TIPC_NLA_LINK_NAME],  		    TIPC_MAX_LINK_NAME);  	return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO, diff --git a/net/tipc/node.c b/net/tipc/node.c index 83978d5dae59..008670d1f43e 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -82,7 +82,7 @@ struct tipc_bclink_entry {  /**   * struct tipc_node - TIPC node structure   * @addr: network address of node - * @ref: reference counter to node object + * @kref: reference counter to node object   * @lock: rwlock governing access to structure   * @net: the applicable net namespace   * @hash: links to adjacent nodes in unsorted hash chain @@ -90,9 +90,11 @@ struct tipc_bclink_entry {   * @namedq: pointer to name table input queue with name table messages   * @active_links: bearer ids of active links, used as index into links[] array   * @links: array containing references to all links to node + * @bc_entry: broadcast link entry   * @action_flags: bit mask of different types of node actions   * @state: connectivity state vs peer node   * @preliminary: a preliminary node or not + * @failover_sent: failover sent or not   * @sync_point: sequence number where synch/failover is finished   * @list: links to adjacent nodes in sorted list of cluster's nodes   * @working_links: number of working links to node (both active and standby) @@ -100,9 +102,16 @@ struct tipc_bclink_entry {   * @capabilities: bitmap, indicating peer node's functional capabilities   * @signature: node instance identifier   * @link_id: local and remote bearer ids of changing link, if any + * @peer_id: 128-bit ID of peer + * @peer_id_string: ID string of peer   * @publ_list: list of publications + * @conn_sks: list of connections (FIXME) + * @timer: node's keepalive timer + * @keepalive_intv: keepalive interval in milliseconds   * @rcu: rcu struct for tipc_node   * @delete_at: indicates the time for deleting a down node + * @peer_net: peer's net namespace + * @peer_hash_mix: hash for this peer (FIXME)   * @crypto_rx: RX crypto handler   */  struct tipc_node { @@ -267,6 +276,7 @@ char *tipc_node_get_id_str(struct tipc_node *node)  #ifdef CONFIG_TIPC_CRYPTO  /**   * tipc_node_crypto_rx - Retrieve crypto RX handle from node + * @__n: target tipc_node   * Note: node ref counter must be held first!   */  struct tipc_crypto *tipc_node_crypto_rx(struct tipc_node *__n) @@ -814,6 +824,9 @@ static void tipc_node_timeout(struct timer_list *t)  /**   * __tipc_node_link_up - handle addition of link + * @n: target tipc_node + * @bearer_id: id of the bearer + * @xmitq: queue for messages to be xmited on   * Node lock must be held by caller   * Link becomes active (alone or shared) or standby, depending on its priority.   */ @@ -880,6 +893,9 @@ static void __tipc_node_link_up(struct tipc_node *n, int bearer_id,  /**   * tipc_node_link_up - handle addition of link + * @n: target tipc_node + * @bearer_id: id of the bearer + * @xmitq: queue for messages to be xmited on   *   * Link becomes active (alone or shared) or standby, depending on its priority.   */ @@ -900,10 +916,11 @@ static void tipc_node_link_up(struct tipc_node *n, int bearer_id,   *   * This function is only called in a very special situation where link   * failover can be already started on peer node but not on this node. - * This can happen when e.g. + * This can happen when e.g.:: + *   *	1. Both links <1A-2A>, <1B-2B> down   *	2. Link endpoint 2A up, but 1A still down (e.g. due to network - *	   disturbance, wrong session, etc.) + *	disturbance, wrong session, etc.)   *	3. Link <1B-2B> up   *	4. Link endpoint 2A down (e.g. due to link tolerance timeout)   *	5. Node 2 starts failover onto link <1B-2B> @@ -940,6 +957,10 @@ static void tipc_node_link_failover(struct tipc_node *n, struct tipc_link *l,  /**   * __tipc_node_link_down - handle loss of link + * @n: target tipc_node + * @bearer_id: id of the bearer + * @xmitq: queue for messages to be xmited on + * @maddr: output media address of the bearer   */  static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,  				  struct sk_buff_head *xmitq, @@ -1525,11 +1546,13 @@ static void node_lost_contact(struct tipc_node *n,  /**   * tipc_node_get_linkname - get the name of a link   * + * @net: the applicable net namespace   * @bearer_id: id of the bearer   * @addr: peer node address   * @linkname: link name output buffer + * @len: size of @linkname output buffer   * - * Returns 0 on success + * Return: 0 on success   */  int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr,  			   char *linkname, size_t len) @@ -1638,17 +1661,17 @@ static void tipc_lxc_xmit(struct net *peer_net, struct sk_buff_head *list)  		return;  	default:  		return; -	}; +	}  }  /** - * tipc_node_xmit() is the general link level function for message sending + * tipc_node_xmit() - general link level function for message sending   * @net: the applicable net namespace   * @list: chain of buffers containing message   * @dnode: address of destination node   * @selector: a number used for deterministic link selection   * Consumes the buffer chain. - * Returns 0 if success, otherwise: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE,-ENOBUF + * Return: 0 if success, otherwise: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE,-ENOBUF   */  int tipc_node_xmit(struct net *net, struct sk_buff_head *list,  		   u32 dnode, int selector) @@ -1881,9 +1904,11 @@ static void tipc_node_bc_rcv(struct net *net, struct sk_buff *skb, int bearer_id  /**   * tipc_node_check_state - check and if necessary update node state + * @n: target tipc_node   * @skb: TIPC packet   * @bearer_id: identity of bearer delivering the packet - * Returns true if state and msg are ok, otherwise false + * @xmitq: queue for messages to be xmited on + * Return: true if state and msg are ok, otherwise false   */  static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb,  				  int bearer_id, struct sk_buff_head *xmitq) @@ -2199,6 +2224,9 @@ int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info)  	struct tipc_net *tn = net_generic(net, tipc_net_id);  	struct nlattr *attrs[TIPC_NLA_NET_MAX + 1];  	struct tipc_node *peer, *temp_node; +	u8 node_id[NODE_ID_LEN]; +	u64 *w0 = (u64 *)&node_id[0]; +	u64 *w1 = (u64 *)&node_id[8];  	u32 addr;  	int err; @@ -2212,10 +2240,22 @@ int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info)  	if (err)  		return err; -	if (!attrs[TIPC_NLA_NET_ADDR]) -		return -EINVAL; +	/* attrs[TIPC_NLA_NET_NODEID] and attrs[TIPC_NLA_NET_ADDR] are +	 * mutually exclusive cases +	 */ +	if (attrs[TIPC_NLA_NET_ADDR]) { +		addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); +		if (!addr) +			return -EINVAL; +	} -	addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]); +	if (attrs[TIPC_NLA_NET_NODEID]) { +		if (!attrs[TIPC_NLA_NET_NODEID_W1]) +			return -EINVAL; +		*w0 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID]); +		*w1 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID_W1]); +		addr = hash128to32(node_id); +	}  	if (in_own_node(net, addr))  		return -ENOTSUPP; diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e795a8a2955b..cebcc104dc70 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -1,8 +1,9 @@  /*   * net/tipc/socket.c: TIPC socket API   * - * Copyright (c) 2001-2007, 2012-2017, Ericsson AB + * Copyright (c) 2001-2007, 2012-2019, Ericsson AB   * Copyright (c) 2004-2008, 2010-2013, Wind River Systems + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -79,19 +80,32 @@ struct sockaddr_pair {   * @maxnagle: maximum size of msg which can be subject to nagle   * @portid: unique port identity in TIPC socket hash table   * @phdr: preformatted message header used when sending messages - * #cong_links: list of congested links + * @cong_links: list of congested links   * @publications: list of publications for port   * @blocking_link: address of the congested link we are currently sleeping on   * @pub_count: total # of publications port has made during its lifetime   * @conn_timeout: the time we can wait for an unresponded setup request + * @probe_unacked: probe has not received ack yet   * @dupl_rcvcnt: number of bytes counted twice, in both backlog and rcv queue   * @cong_link_cnt: number of congested links   * @snt_unacked: # messages sent by socket, and not yet acked by peer + * @snd_win: send window size + * @peer_caps: peer capabilities mask   * @rcv_unacked: # messages read by user, but not yet acked back to peer + * @rcv_win: receive window size   * @peer: 'connected' peer for dgram/rdm   * @node: hash table node   * @mc_method: cookie for use between socket and broadcast layer   * @rcu: rcu struct for tipc_sock + * @group: TIPC communications group + * @oneway: message count in one direction (FIXME) + * @nagle_start: current nagle value + * @snd_backlog: send backlog count + * @msg_acc: messages accepted; used in managing backlog and nagle + * @pkt_cnt: TIPC socket packet count + * @expect_ack: whether this TIPC socket is expecting an ack + * @nodelay: setsockopt() TIPC_NODELAY setting + * @group_is_open: TIPC socket group is fully open (FIXME)   */  struct tipc_sock {  	struct sock sk; @@ -138,9 +152,9 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags,  		       bool kern);  static void tipc_sk_timeout(struct timer_list *t);  static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, -			   struct tipc_name_seq const *seq); +			   struct tipc_service_range const *seq);  static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, -			    struct tipc_name_seq const *seq); +			    struct tipc_service_range const *seq);  static int tipc_sk_leave(struct tipc_sock *tsk);  static struct tipc_sock *tipc_sk_lookup(struct net *net, u32 portid);  static int tipc_sk_insert(struct tipc_sock *tsk); @@ -260,6 +274,7 @@ static void tsk_set_nagle(struct tipc_sock *tsk)  /**   * tsk_advance_rx_queue - discard first buffer in socket receive queue + * @sk: network socket   *   * Caller must hold socket lock   */ @@ -288,6 +303,8 @@ static void tipc_sk_respond(struct sock *sk, struct sk_buff *skb, int err)  /**   * tsk_rej_rx_queue - reject all buffers in socket receive queue + * @sk: network socket + * @error: response error code   *   * Caller must hold socket lock   */ @@ -441,7 +458,7 @@ static int tipc_sk_sock_err(struct socket *sock, long *timeout)   * This routine creates additional data structures used by the TIPC socket,   * initializes them, and links them together.   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_sk_create(struct net *net, struct socket *sock,  			  int protocol, int kern) @@ -606,7 +623,7 @@ static void __tipc_shutdown(struct socket *sock, int error)   * are returned or discarded according to the "destination droppable" setting   * specified for the message by the sender.   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_release(struct socket *sock)  { @@ -644,75 +661,77 @@ static int tipc_release(struct socket *sock)  }  /** - * tipc_bind - associate or disassocate TIPC name(s) with a socket + * __tipc_bind - associate or disassocate TIPC name(s) with a socket   * @sock: socket structure - * @uaddr: socket address describing name(s) and desired operation - * @uaddr_len: size of socket address data structure + * @skaddr: socket address describing name(s) and desired operation + * @alen: size of socket address data structure   *   * Name and name sequence binding is indicated using a positive scope value;   * a negative scope value unbinds the specified name.  Specifying no name   * (i.e. a socket address length of 0) unbinds all names from the socket.   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   *   * NOTE: This routine doesn't need to take the socket lock since it doesn't   *       access any non-constant socket information.   */ -static int tipc_bind(struct socket *sock, struct sockaddr *uaddr, -		     int uaddr_len) +static int __tipc_bind(struct socket *sock, struct sockaddr *skaddr, int alen)  { -	struct sock *sk = sock->sk; -	struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr; -	struct tipc_sock *tsk = tipc_sk(sk); -	int res = -EINVAL; +	struct sockaddr_tipc *addr = (struct sockaddr_tipc *)skaddr; +	struct tipc_sock *tsk = tipc_sk(sock->sk); -	lock_sock(sk); -	if (unlikely(!uaddr_len)) { -		res = tipc_sk_withdraw(tsk, 0, NULL); -		goto exit; -	} -	if (tsk->group) { -		res = -EACCES; -		goto exit; -	} -	if (uaddr_len < sizeof(struct sockaddr_tipc)) { -		res = -EINVAL; -		goto exit; -	} -	if (addr->family != AF_TIPC) { -		res = -EAFNOSUPPORT; -		goto exit; -	} +	if (unlikely(!alen)) +		return tipc_sk_withdraw(tsk, 0, NULL); -	if (addr->addrtype == TIPC_ADDR_NAME) +	if (addr->addrtype == TIPC_SERVICE_ADDR)  		addr->addr.nameseq.upper = addr->addr.nameseq.lower; -	else if (addr->addrtype != TIPC_ADDR_NAMESEQ) { -		res = -EAFNOSUPPORT; -		goto exit; -	} -	if ((addr->addr.nameseq.type < TIPC_RESERVED_TYPES) && -	    (addr->addr.nameseq.type != TIPC_TOP_SRV) && -	    (addr->addr.nameseq.type != TIPC_CFG_SRV)) { -		res = -EACCES; -		goto exit; -	} +	if (tsk->group) +		return -EACCES; -	res = (addr->scope >= 0) ? -		tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : -		tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); -exit: -	release_sock(sk); +	if (addr->scope >= 0) +		return tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq); +	else +		return tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); +} + +int tipc_sk_bind(struct socket *sock, struct sockaddr *skaddr, int alen) +{ +	int res; + +	lock_sock(sock->sk); +	res = __tipc_bind(sock, skaddr, alen); +	release_sock(sock->sk);  	return res;  } +static int tipc_bind(struct socket *sock, struct sockaddr *skaddr, int alen) +{ +	struct sockaddr_tipc *addr = (struct sockaddr_tipc *)skaddr; + +	if (alen) { +		if (alen < sizeof(struct sockaddr_tipc)) +			return -EINVAL; +		if (addr->family != AF_TIPC) +			return -EAFNOSUPPORT; +		if (addr->addrtype > TIPC_SERVICE_ADDR) +			return -EAFNOSUPPORT; +		if (addr->addr.nameseq.type < TIPC_RESERVED_TYPES) { +			pr_warn_once("Can't bind to reserved service type %u\n", +				     addr->addr.nameseq.type); +			return -EACCES; +		} +	} +	return tipc_sk_bind(sock, skaddr, alen); +} +  /**   * tipc_getname - get port ID of socket or peer socket   * @sock: socket structure   * @uaddr: area for returned socket address   * @peer: 0 = own ID, 1 = current peer ID, 2 = current/former peer ID   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   *   * NOTE: This routine doesn't need to take the socket lock since it only   *       accesses socket information that is unchanging (or which changes in @@ -737,7 +756,7 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,  		addr->addr.id.node = tipc_own_addr(sock_net(sk));  	} -	addr->addrtype = TIPC_ADDR_ID; +	addr->addrtype = TIPC_SOCKET_ADDR;  	addr->family = AF_TIPC;  	addr->scope = 0;  	addr->addr.name.domain = 0; @@ -751,7 +770,7 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,   * @sock: socket for which to calculate the poll bits   * @wait: ???   * - * Returns pollmask value + * Return: pollmask value   *   * COMMENTARY:   * It appears that the usual socket locking mechanisms are not useful here @@ -813,9 +832,9 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,   * @timeout: timeout to wait for wakeup   *   * Called from function tipc_sendmsg(), which has done all sanity checks - * Returns the number of bytes sent on success, or errno + * Return: the number of bytes sent on success, or errno   */ -static int tipc_sendmcast(struct  socket *sock, struct tipc_name_seq *seq, +static int tipc_sendmcast(struct  socket *sock, struct tipc_service_range *seq,  			  struct msghdr *msg, size_t dlen, long timeout)  {  	struct sock *sk = sock->sk; @@ -873,6 +892,7 @@ static int tipc_sendmcast(struct  socket *sock, struct tipc_name_seq *seq,  /**   * tipc_send_group_msg - send a message to a member in the group   * @net: network namespace + * @tsk: tipc socket   * @m: message to send   * @mb: group member   * @dnode: destination node @@ -928,7 +948,7 @@ static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk,   * @timeout: timeout to wait for wakeup   *   * Called from function tipc_sendmsg(), which has done all sanity checks - * Returns the number of bytes sent on success, or errno + * Return: the number of bytes sent on success, or errno   */  static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,  				   int dlen, long timeout) @@ -972,7 +992,7 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,   * @timeout: timeout to wait for wakeup   *   * Called from function tipc_sendmsg(), which has done all sanity checks - * Returns the number of bytes sent on success, or errno + * Return: the number of bytes sent on success, or errno   */  static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,  				   int dlen, long timeout) @@ -1057,7 +1077,7 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,   * @timeout: timeout to wait for wakeup   *   * Called from function tipc_sendmsg(), which has done all sanity checks - * Returns the number of bytes sent on success, or errno + * Return: the number of bytes sent on success, or errno   */  static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,  				 int dlen, long timeout) @@ -1131,7 +1151,7 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,   * @timeout: timeout to wait for wakeup   *   * Called from function tipc_sendmsg(), which has done all sanity checks - * Returns the number of bytes sent on success, or errno + * Return: the number of bytes sent on success, or errno   */  static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,  				 int dlen, long timeout) @@ -1168,6 +1188,7 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,  /**   * tipc_sk_mcast_rcv - Deliver multicast messages to all destination sockets + * @net: the associated network namespace   * @arrvq: queue with arriving messages, to be cloned after destination lookup   * @inputq: queue with cloned messages, delivered to socket after dest lookup   * @@ -1307,6 +1328,8 @@ static void tipc_sk_push_backlog(struct tipc_sock *tsk, bool nagle_ack)   * tipc_sk_conn_proto_rcv - receive a connection mng protocol message   * @tsk: receiving socket   * @skb: pointer to message buffer. + * @inputq: buffer list containing the buffers + * @xmitq: output message area   */  static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,  				   struct sk_buff_head *inputq, @@ -1374,7 +1397,7 @@ exit:   * and for 'SYN' messages on SOCK_SEQPACKET and SOCK_STREAM connections.   * (Note: 'SYN+' is prohibited on SOCK_STREAM.)   * - * Returns the number of bytes sent on success, or errno otherwise + * Return: the number of bytes sent on success, or errno otherwise   */  static int tipc_sendmsg(struct socket *sock,  			struct msghdr *m, size_t dsz) @@ -1400,7 +1423,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)  	bool syn = !tipc_sk_type_connectionless(sk);  	struct tipc_group *grp = tsk->group;  	struct tipc_msg *hdr = &tsk->phdr; -	struct tipc_name_seq *seq; +	struct tipc_service_range *seq;  	struct sk_buff_head pkts;  	u32 dport = 0, dnode = 0;  	u32 type = 0, inst = 0; @@ -1419,9 +1442,9 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)  	if (grp) {  		if (!dest)  			return tipc_send_group_bcast(sock, m, dlen, timeout); -		if (dest->addrtype == TIPC_ADDR_NAME) +		if (dest->addrtype == TIPC_SERVICE_ADDR)  			return tipc_send_group_anycast(sock, m, dlen, timeout); -		if (dest->addrtype == TIPC_ADDR_ID) +		if (dest->addrtype == TIPC_SOCKET_ADDR)  			return tipc_send_group_unicast(sock, m, dlen, timeout);  		if (dest->addrtype == TIPC_ADDR_MCAST)  			return tipc_send_group_mcast(sock, m, dlen, timeout); @@ -1441,7 +1464,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)  			return -EISCONN;  		if (tsk->published)  			return -EOPNOTSUPP; -		if (dest->addrtype == TIPC_ADDR_NAME) { +		if (dest->addrtype == TIPC_SERVICE_ADDR) {  			tsk->conn_type = dest->addr.name.name.type;  			tsk->conn_instance = dest->addr.name.name.instance;  		} @@ -1452,14 +1475,14 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)  	if (dest->addrtype == TIPC_ADDR_MCAST)  		return tipc_sendmcast(sock, seq, m, dlen, timeout); -	if (dest->addrtype == TIPC_ADDR_NAME) { +	if (dest->addrtype == TIPC_SERVICE_ADDR) {  		type = dest->addr.name.name.type;  		inst = dest->addr.name.name.instance;  		dnode = dest->addr.name.domain;  		dport = tipc_nametbl_translate(net, type, inst, &dnode);  		if (unlikely(!dport && !dnode))  			return -EHOSTUNREACH; -	} else if (dest->addrtype == TIPC_ADDR_ID) { +	} else if (dest->addrtype == TIPC_SOCKET_ADDR) {  		dnode = dest->addr.id.node;  	} else {  		return -EINVAL; @@ -1471,7 +1494,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)  	if (unlikely(rc))  		return rc; -	if (dest->addrtype == TIPC_ADDR_NAME) { +	if (dest->addrtype == TIPC_SERVICE_ADDR) {  		msg_set_type(hdr, TIPC_NAMED_MSG);  		msg_set_hdr_sz(hdr, NAMED_H_SIZE);  		msg_set_nametype(hdr, type); @@ -1479,7 +1502,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)  		msg_set_lookup_scope(hdr, tipc_node2scope(dnode));  		msg_set_destnode(hdr, dnode);  		msg_set_destport(hdr, dport); -	} else { /* TIPC_ADDR_ID */ +	} else { /* TIPC_SOCKET_ADDR */  		msg_set_type(hdr, TIPC_DIRECT_MSG);  		msg_set_lookup_scope(hdr, 0);  		msg_set_destnode(hdr, dnode); @@ -1519,7 +1542,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)   *   * Used for SOCK_STREAM data.   * - * Returns the number of bytes sent on success (or partial success), + * Return: the number of bytes sent on success (or partial success),   * or errno if no data sent   */  static int tipc_sendstream(struct socket *sock, struct msghdr *m, size_t dsz) @@ -1627,7 +1650,7 @@ static int __tipc_sendstream(struct socket *sock, struct msghdr *m, size_t dlen)   *   * Used for SOCK_SEQPACKET messages.   * - * Returns the number of bytes sent on success, or errno otherwise + * Return: the number of bytes sent on success, or errno otherwise   */  static int tipc_send_packet(struct socket *sock, struct msghdr *m, size_t dsz)  { @@ -1684,7 +1707,7 @@ static void tipc_sk_set_orig_addr(struct msghdr *m, struct sk_buff *skb)  		return;  	srcaddr->sock.family = AF_TIPC; -	srcaddr->sock.addrtype = TIPC_ADDR_ID; +	srcaddr->sock.addrtype = TIPC_SOCKET_ADDR;  	srcaddr->sock.scope = 0;  	srcaddr->sock.addr.id.ref = msg_origport(hdr);  	srcaddr->sock.addr.id.node = msg_orignode(hdr); @@ -1696,7 +1719,7 @@ static void tipc_sk_set_orig_addr(struct msghdr *m, struct sk_buff *skb)  	/* Group message users may also want to know sending member's id */  	srcaddr->member.family = AF_TIPC; -	srcaddr->member.addrtype = TIPC_ADDR_NAME; +	srcaddr->member.addrtype = TIPC_SERVICE_ADDR;  	srcaddr->member.scope = 0;  	srcaddr->member.addr.name.name.type = msg_nametype(hdr);  	srcaddr->member.addr.name.name.instance = TIPC_SKB_CB(skb)->orig_member; @@ -1712,7 +1735,7 @@ static void tipc_sk_set_orig_addr(struct msghdr *m, struct sk_buff *skb)   *   * Note: Ancillary data is not captured if not requested by receiver.   * - * Returns 0 if successful, otherwise errno + * Return: 0 if successful, otherwise errno   */  static int tipc_sk_anc_data_recv(struct msghdr *m, struct sk_buff *skb,  				 struct tipc_sock *tsk) @@ -1862,6 +1885,7 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)  /**   * tipc_recvmsg - receive packet-oriented message + * @sock: network socket   * @m: descriptor for message info   * @buflen: length of user buffer area   * @flags: receive flags @@ -1869,7 +1893,7 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)   * Used for SOCK_DGRAM, SOCK_RDM, and SOCK_SEQPACKET messages.   * If the complete message doesn't fit in user area, truncate it.   * - * Returns size of returned message data, errno otherwise + * Return: size of returned message data, errno otherwise   */  static int tipc_recvmsg(struct socket *sock, struct msghdr *m,  			size_t buflen,	int flags) @@ -1970,6 +1994,7 @@ exit:  /**   * tipc_recvstream - receive stream-oriented data + * @sock: network socket   * @m: descriptor for message info   * @buflen: total size of user buffer area   * @flags: receive flags @@ -1977,7 +2002,7 @@ exit:   * Used for SOCK_STREAM messages only.  If not enough data is available   * will optionally wait for more; never truncates data.   * - * Returns size of returned message data, errno otherwise + * Return: size of returned message data, errno otherwise   */  static int tipc_recvstream(struct socket *sock, struct msghdr *m,  			   size_t buflen, int flags) @@ -2155,7 +2180,7 @@ static void tipc_sk_proto_rcv(struct sock *sk,   * @tsk: TIPC socket   * @skb: pointer to message buffer.   * @xmitq: for Nagle ACK if any - * Returns true if message should be added to receive queue, false otherwise + * Return: true if message should be added to receive queue, false otherwise   */  static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,  				   struct sk_buff_head *xmitq) @@ -2269,7 +2294,7 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,   * TIPC_HIGH_IMPORTANCE      (8 MB)   * TIPC_CRITICAL_IMPORTANCE  (16 MB)   * - * Returns overload limit according to corresponding message importance + * Return: overload limit according to corresponding message importance   */  static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *skb)  { @@ -2292,12 +2317,12 @@ static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *skb)   * tipc_sk_filter_rcv - validate incoming message   * @sk: socket   * @skb: pointer to message. + * @xmitq: output message area (FIXME)   *   * Enqueues message on receive queue if acceptable; optionally handles   * disconnect indication for a connected socket.   *   * Called with socket lock already taken - *   */  static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,  			       struct sk_buff_head *xmitq) @@ -2387,6 +2412,7 @@ static int tipc_sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)   * @inputq: list of incoming buffers with potentially different destinations   * @sk: socket where the buffers should be enqueued   * @dport: port number for the socket + * @xmitq: output queue   *   * Caller must hold socket lock   */ @@ -2439,6 +2465,7 @@ static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,  /**   * tipc_sk_rcv - handle a chain of incoming buffers + * @net: the associated network namespace   * @inputq: buffer list containing the buffers   * Consumes all buffers in list until inputq is empty   * Note: may be called in multiple threads referring to the same queue @@ -2531,7 +2558,7 @@ static bool tipc_sockaddr_is_sane(struct sockaddr_tipc *addr)   * @destlen: size of socket address data structure   * @flags: file-related flags associated with socket   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_connect(struct socket *sock, struct sockaddr *dest,  			int destlen, int flags) @@ -2624,7 +2651,7 @@ exit:   * @sock: socket structure   * @len: (unused)   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_listen(struct socket *sock, int len)  { @@ -2676,8 +2703,9 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo)   * @sock: listening socket   * @new_sock: new socket that is to be connected   * @flags: file-related flags associated with socket + * @kern: caused by kernel or by userspace?   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags,  		       bool kern) @@ -2756,7 +2784,7 @@ exit:   *   * Terminates connection (if necessary), then purges socket's receive queue.   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_shutdown(struct socket *sock, int how)  { @@ -2864,7 +2892,7 @@ static void tipc_sk_timeout(struct timer_list *t)  }  static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, -			   struct tipc_name_seq const *seq) +			   struct tipc_service_range const *seq)  {  	struct sock *sk = &tsk->sk;  	struct net *net = sock_net(sk); @@ -2892,7 +2920,7 @@ static int tipc_sk_publish(struct tipc_sock *tsk, uint scope,  }  static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, -			    struct tipc_name_seq const *seq) +			    struct tipc_service_range const *seq)  {  	struct net *net = sock_net(&tsk->sk);  	struct publication *publ; @@ -3039,7 +3067,7 @@ static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq)  	struct net *net = sock_net(&tsk->sk);  	struct tipc_group *grp = tsk->group;  	struct tipc_msg *hdr = &tsk->phdr; -	struct tipc_name_seq seq; +	struct tipc_service_range seq;  	int rc;  	if (mreq->type < TIPC_RESERVED_TYPES) @@ -3076,7 +3104,7 @@ static int tipc_sk_leave(struct tipc_sock *tsk)  {  	struct net *net = sock_net(&tsk->sk);  	struct tipc_group *grp = tsk->group; -	struct tipc_name_seq seq; +	struct tipc_service_range seq;  	int scope;  	if (!grp) @@ -3099,7 +3127,7 @@ static int tipc_sk_leave(struct tipc_sock *tsk)   * For stream sockets only, accepts and ignores all IPPROTO_TCP options   * (to ease compatibility).   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_setsockopt(struct socket *sock, int lvl, int opt,  			   sockptr_t ov, unsigned int ol) @@ -3193,14 +3221,14 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,   * For stream sockets only, returns 0 length result for all IPPROTO_TCP options   * (to ease compatibility).   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  static int tipc_getsockopt(struct socket *sock, int lvl, int opt,  			   char __user *ov, int __user *ol)  {  	struct sock *sk = sock->sk;  	struct tipc_sock *tsk = tipc_sk(sk); -	struct tipc_name_seq seq; +	struct tipc_service_range seq;  	int len, scope;  	u32 value;  	int res; @@ -3301,12 +3329,12 @@ static int tipc_socketpair(struct socket *sock1, struct socket *sock2)  	u32 onode = tipc_own_addr(sock_net(sock1->sk));  	tsk1->peer.family = AF_TIPC; -	tsk1->peer.addrtype = TIPC_ADDR_ID; +	tsk1->peer.addrtype = TIPC_SOCKET_ADDR;  	tsk1->peer.scope = TIPC_NODE_SCOPE;  	tsk1->peer.addr.id.ref = tsk2->portid;  	tsk1->peer.addr.id.node = onode;  	tsk2->peer.family = AF_TIPC; -	tsk2->peer.addrtype = TIPC_ADDR_ID; +	tsk2->peer.addrtype = TIPC_SOCKET_ADDR;  	tsk2->peer.scope = TIPC_NODE_SCOPE;  	tsk2->peer.addr.id.ref = tsk1->portid;  	tsk2->peer.addr.id.node = onode; @@ -3397,7 +3425,7 @@ static struct proto tipc_proto = {  /**   * tipc_socket_init - initialize TIPC socket interface   * - * Returns 0 on success, errno otherwise + * Return: 0 on success, errno otherwise   */  int tipc_socket_init(void)  { @@ -3796,10 +3824,11 @@ int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb)  /**   * tipc_sk_filtering - check if a socket should be traced   * @sk: the socket to be examined - * @sysctl_tipc_sk_filter[]: the socket tuple for filtering, - *  (portid, sock type, name type, name lower, name upper)   * - * Returns true if the socket meets the socket tuple data + * @sysctl_tipc_sk_filter is used as the socket tuple for filtering: + * (portid, sock type, name type, name lower, name upper) + * + * Return: true if the socket meets the socket tuple data   * (value 0 = 'any') or when there is no tuple set (all = 0),   * otherwise false   */ @@ -3864,7 +3893,7 @@ u32 tipc_sock_get_portid(struct sock *sk)   * @sk: tipc sk to be checked   * @skb: tipc msg to be checked   * - * Returns true if the socket rx queue allocation is > 90%, otherwise false + * Return: true if the socket rx queue allocation is > 90%, otherwise false   */  bool tipc_sk_overlimit1(struct sock *sk, struct sk_buff *skb) @@ -3882,7 +3911,7 @@ bool tipc_sk_overlimit1(struct sock *sk, struct sk_buff *skb)   * @sk: tipc sk to be checked   * @skb: tipc msg to be checked   * - * Returns true if the socket rx queue allocation is > 90%, otherwise false + * Return: true if the socket rx queue allocation is > 90%, otherwise false   */  bool tipc_sk_overlimit2(struct sock *sk, struct sk_buff *skb) diff --git a/net/tipc/socket.h b/net/tipc/socket.h index b11575afc66f..02cdf166807d 100644 --- a/net/tipc/socket.h +++ b/net/tipc/socket.h @@ -74,7 +74,7 @@ int tipc_dump_done(struct netlink_callback *cb);  u32 tipc_sock_get_portid(struct sock *sk);  bool tipc_sk_overlimit1(struct sock *sk, struct sk_buff *skb);  bool tipc_sk_overlimit2(struct sock *sk, struct sk_buff *skb); - +int tipc_sk_bind(struct socket *sock, struct sockaddr *skaddr, int alen);  int tsk_set_importance(struct sock *sk, int imp);  #endif diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index f340e53da625..f6ad0005218c 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c @@ -3,6 +3,7 @@   *   * Copyright (c) 2000-2017, Ericsson AB   * Copyright (c) 2005-2007, 2010-2013, Wind River Systems + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -55,12 +56,14 @@ static void tipc_sub_send_event(struct tipc_subscription *sub,  }  /** - * tipc_sub_check_overlap - test for subscription overlap with the - * given values + * tipc_sub_check_overlap - test for subscription overlap with the given values + * @seq: tipc_name_seq to check + * @found_lower: lower value to test + * @found_upper: upper value to test   * - * Returns 1 if there is overlap, otherwise 0. + * Return: 1 if there is overlap, otherwise 0.   */ -int tipc_sub_check_overlap(struct tipc_name_seq *seq, u32 found_lower, +int tipc_sub_check_overlap(struct tipc_service_range *seq, u32 found_lower,  			   u32 found_upper)  {  	if (found_lower < seq->lower) @@ -79,7 +82,7 @@ void tipc_sub_report_overlap(struct tipc_subscription *sub,  {  	struct tipc_subscr *s = &sub->evt.s;  	u32 filter = tipc_sub_read(s, filter); -	struct tipc_name_seq seq; +	struct tipc_service_range seq;  	seq.type = tipc_sub_read(s, seq.type);  	seq.lower = tipc_sub_read(s, seq.lower); diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h index 6ebbec1bedd1..3ded27391d54 100644 --- a/net/tipc/subscr.h +++ b/net/tipc/subscr.h @@ -3,6 +3,7 @@   *   * Copyright (c) 2003-2017, Ericsson AB   * Copyright (c) 2005-2007, 2012-2013, Wind River Systems + * Copyright (c) 2020, Red Hat Inc   * All rights reserved.   *   * Redistribution and use in source and binary forms, with or without @@ -47,12 +48,15 @@ struct tipc_conn;  /**   * struct tipc_subscription - TIPC network topology subscription object - * @subscriber: pointer to its subscriber - * @seq: name sequence associated with subscription + * @kref: reference count for this subscription + * @net: network namespace associated with subscription   * @timer: timer governing subscription duration (optional) - * @nameseq_list: adjacent subscriptions in name sequence's subscription list + * @service_list: adjacent subscriptions in name sequence's subscription list   * @sub_list: adjacent subscriptions in subscriber's subscription list   * @evt: template for events generated by subscription + * @conid: connection identifier of topology server + * @inactive: true if this subscription is inactive + * @lock: serialize up/down and timer events   */  struct tipc_subscription {  	struct kref kref; @@ -63,7 +67,7 @@ struct tipc_subscription {  	struct tipc_event evt;  	int conid;  	bool inactive; -	spinlock_t lock; /* serialize up/down and timer events */ +	spinlock_t lock;  };  struct tipc_subscription *tipc_sub_subscribe(struct net *net, @@ -71,8 +75,8 @@ struct tipc_subscription *tipc_sub_subscribe(struct net *net,  					     int conid);  void tipc_sub_unsubscribe(struct tipc_subscription *sub); -int tipc_sub_check_overlap(struct tipc_name_seq *seq, u32 found_lower, -			   u32 found_upper); +int tipc_sub_check_overlap(struct tipc_service_range *seq, +			   u32 found_lower, u32 found_upper);  void tipc_sub_report_overlap(struct tipc_subscription *sub,  			     u32 found_lower, u32 found_upper,  			     u32 event, u32 port, u32 node, diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c index 13f3143609f9..5522865deae9 100644 --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c @@ -519,13 +519,13 @@ static int tipc_topsrv_create_listener(struct tipc_topsrv *srv)  		goto err;  	saddr.family	                = AF_TIPC; -	saddr.addrtype		        = TIPC_ADDR_NAMESEQ; -	saddr.addr.nameseq.type	        = TIPC_TOP_SRV; +	saddr.addrtype		        = TIPC_SERVICE_RANGE; +	saddr.addr.nameseq.type	= TIPC_TOP_SRV;  	saddr.addr.nameseq.lower	= TIPC_TOP_SRV;  	saddr.addr.nameseq.upper	= TIPC_TOP_SRV;  	saddr.scope			= TIPC_NODE_SCOPE; -	rc = kernel_bind(lsock, (struct sockaddr *)&saddr, sizeof(saddr)); +	rc = tipc_sk_bind(lsock, (struct sockaddr *)&saddr, sizeof(saddr));  	if (rc < 0)  		goto err;  	rc = kernel_listen(lsock, 0); diff --git a/net/tipc/trace.c b/net/tipc/trace.c index 265f6a26aa3d..7d2931521e0e 100644 --- a/net/tipc/trace.c +++ b/net/tipc/trace.c @@ -36,7 +36,7 @@  #define CREATE_TRACE_POINTS  #include "trace.h" -/** +/*   * socket tuples for filtering in socket traces:   * (portid, sock type, name type, name lower, name upper)   */ diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 1d17f4470ee2..21e75e28e86a 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -64,6 +64,11 @@   *   * This is the bearer level originating address used in neighbor discovery   * messages, and all fields should be in network byte order + * + * @proto: Ethernet protocol in use + * @port: port being used + * @ipv4: IPv4 address of neighbor + * @ipv6: IPv6 address of neighbor   */  struct udp_media_addr {  	__be16	proto; @@ -88,6 +93,7 @@ struct udp_replicast {   * @ubsock:	bearer associated socket   * @ifindex:	local address scope   * @work:	used to schedule deferred work on a bearer + * @rcast:	associated udp_replicast container   */  struct udp_bearer {  	struct tipc_bearer __rcu *bearer; @@ -772,7 +778,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,  	if (err)  		goto free; -	/** +	/*  	 * The bcast media address port is used for all peers and the ip  	 * is used if it's a multicast address.  	 */  | 
