mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net/smc: Add netlink net namespace support
This adds net namespace ID to diag of linkgroup, helps us to distinguish different namespaces, and net_cookie is unique in the whole system. Signed-off-by: Tony Lu <tonylu@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									0237a3a683
								
							
						
					
					
						commit
						79d39fc503
					
				
					 4 changed files with 20 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -119,6 +119,8 @@ enum {
 | 
			
		|||
	SMC_NLA_LGR_R_CONNS_NUM,	/* u32 */
 | 
			
		||||
	SMC_NLA_LGR_R_V2_COMMON,	/* nest */
 | 
			
		||||
	SMC_NLA_LGR_R_V2,		/* nest */
 | 
			
		||||
	SMC_NLA_LGR_R_NET_COOKIE,	/* u64 */
 | 
			
		||||
	SMC_NLA_LGR_R_PAD,		/* flag */
 | 
			
		||||
	__SMC_NLA_LGR_R_MAX,
 | 
			
		||||
	SMC_NLA_LGR_R_MAX = __SMC_NLA_LGR_R_MAX - 1
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,11 +84,12 @@ struct smc_diag_conninfo {
 | 
			
		|||
/* SMC_DIAG_LINKINFO */
 | 
			
		||||
 | 
			
		||||
struct smc_diag_linkinfo {
 | 
			
		||||
	__u8 link_id;			/* link identifier */
 | 
			
		||||
	__u8 ibname[IB_DEVICE_NAME_MAX]; /* name of the RDMA device */
 | 
			
		||||
	__u8 ibport;			/* RDMA device port number */
 | 
			
		||||
	__u8 gid[40];			/* local GID */
 | 
			
		||||
	__u8 peer_gid[40];		/* peer GID */
 | 
			
		||||
	__u8		link_id;		    /* link identifier */
 | 
			
		||||
	__u8		ibname[IB_DEVICE_NAME_MAX]; /* name of the RDMA device */
 | 
			
		||||
	__u8		ibport;			    /* RDMA device port number */
 | 
			
		||||
	__u8		gid[40];		    /* local GID */
 | 
			
		||||
	__u8		peer_gid[40];		    /* peer GID */
 | 
			
		||||
	__aligned_u64	net_cookie;                 /* RDMA device net namespace */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct smc_diag_lgrinfo {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -348,6 +348,9 @@ static int smc_nl_fill_lgr(struct smc_link_group *lgr,
 | 
			
		|||
		goto errattr;
 | 
			
		||||
	if (nla_put_u8(skb, SMC_NLA_LGR_R_VLAN_ID, lgr->vlan_id))
 | 
			
		||||
		goto errattr;
 | 
			
		||||
	if (nla_put_u64_64bit(skb, SMC_NLA_LGR_R_NET_COOKIE,
 | 
			
		||||
			      lgr->net->net_cookie, SMC_NLA_LGR_R_PAD))
 | 
			
		||||
		goto errattr;
 | 
			
		||||
	memcpy(smc_target, lgr->pnet_id, SMC_MAX_PNETID_LEN);
 | 
			
		||||
	smc_target[SMC_MAX_PNETID_LEN] = 0;
 | 
			
		||||
	if (nla_put_string(skb, SMC_NLA_LGR_R_PNETID, smc_target))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -145,19 +145,21 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
 | 
			
		|||
	if (smc->conn.lgr && !smc->conn.lgr->is_smcd &&
 | 
			
		||||
	    (req->diag_ext & (1 << (SMC_DIAG_LGRINFO - 1))) &&
 | 
			
		||||
	    !list_empty(&smc->conn.lgr->list)) {
 | 
			
		||||
		struct smc_link *link = smc->conn.lnk;
 | 
			
		||||
		struct net *net = read_pnet(&link->smcibdev->ibdev->coredev.rdma_net);
 | 
			
		||||
 | 
			
		||||
		struct smc_diag_lgrinfo linfo = {
 | 
			
		||||
			.role = smc->conn.lgr->role,
 | 
			
		||||
			.lnk[0].ibport = smc->conn.lnk->ibport,
 | 
			
		||||
			.lnk[0].link_id = smc->conn.lnk->link_id,
 | 
			
		||||
			.lnk[0].ibport = link->ibport,
 | 
			
		||||
			.lnk[0].link_id = link->link_id,
 | 
			
		||||
			.lnk[0].net_cookie = net->net_cookie,
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		memcpy(linfo.lnk[0].ibname,
 | 
			
		||||
		       smc->conn.lgr->lnk[0].smcibdev->ibdev->name,
 | 
			
		||||
		       sizeof(smc->conn.lnk->smcibdev->ibdev->name));
 | 
			
		||||
		smc_gid_be16_convert(linfo.lnk[0].gid,
 | 
			
		||||
				     smc->conn.lnk->gid);
 | 
			
		||||
		smc_gid_be16_convert(linfo.lnk[0].peer_gid,
 | 
			
		||||
				     smc->conn.lnk->peer_gid);
 | 
			
		||||
		       sizeof(link->smcibdev->ibdev->name));
 | 
			
		||||
		smc_gid_be16_convert(linfo.lnk[0].gid, link->gid);
 | 
			
		||||
		smc_gid_be16_convert(linfo.lnk[0].peer_gid, link->peer_gid);
 | 
			
		||||
 | 
			
		||||
		if (nla_put(skb, SMC_DIAG_LGRINFO, sizeof(linfo), &linfo) < 0)
 | 
			
		||||
			goto errout;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue