linux/net/smc/smc_pnet.c
/* Parse the supplied netlink attributes and fill a pnetentry structure.
 * For ethernet and infiniband device names verify that the devices exist.
 */
Parse the supplied netlink attributes and fill a pnetentry structure.
For ethernet and infiniband device names verify that the devices exist.
Parse the supplied netlink attributes and fill a pnetentry structure . For ethernet and infiniband device names verify that the devices exist .
static int smc_pnet_fill_entry(struct net *net, struct smc_pnetentry *pnetelem,
			       struct nlattr *tb[])
{
	char *string, *ibname;
	int rc;
	memset(pnetelem, 0, sizeof(*pnetelem));
	INIT_LIST_HEAD(&pnetelem->list);
	rc = -EINVAL;
	if (!tb[SMC_PNETID_NAME])
		goto error;
	string = (char *)nla_data(tb[SMC_PNETID_NAME]);
	if (!smc_pnetid_valid(string, pnetelem->pnet_name))
		goto error;
	rc = -EINVAL;
	if (!tb[SMC_PNETID_ETHNAME])
		goto error;
	rc = -ENOENT;
	string = (char *)nla_data(tb[SMC_PNETID_ETHNAME]);
	pnetelem->ndev = dev_get_by_name(net, string);
	if (!pnetelem->ndev)
		goto error;
	rc = -EINVAL;
	if (!tb[SMC_PNETID_IBNAME])
		goto error;
	rc = -ENOENT;
	ibname = (char *)nla_data(tb[SMC_PNETID_IBNAME]);
	ibname = strim(ibname);
	pnetelem->smcibdev = smc_pnet_find_ib(ibname);
	if (!pnetelem->smcibdev)
		goto error;
	rc = -EINVAL;
	if (!tb[SMC_PNETID_IBPORT])
		goto error;
	pnetelem->ib_port = nla_get_u8(tb[SMC_PNETID_IBPORT]);
	if (pnetelem->ib_port < 1 || pnetelem->ib_port > SMC_MAX_PORTS)
		goto error;
	return 0;
error:
	if (pnetelem->ndev)
		dev_put(pnetelem->ndev);
	return rc;
}
static int smc_pnet_fill_entry ( struct net * net , struct smc_pnetentry * pnetelem , struct nlattr * tb [ ] ) { char * string , * ibname ; int rc ; memset ( pnetelem , 0 , sizeof ( * pnetelem ) ) ; INIT_LIST_HEAD ( & pnetelem -> list ) ; rc = - EINVAL ; if ( ! tb [ SMC_PNETID_NAME ] ) goto error ; string = ( char * ) nla_data ( tb [ SMC_PNETID_NAME ] ) ; if ( ! smc_pnetid_valid ( string , pnetelem -> pnet_name ) ) goto error ; rc = - EINVAL ; if ( ! tb [ SMC_PNETID_ETHNAME ] ) goto error ; rc = - ENOENT ; string = ( char * ) nla_data ( tb [ SMC_PNETID_ETHNAME ] ) ; pnetelem -> ndev = dev_get_by_name ( net , string ) ; if ( ! pnetelem -> ndev ) goto error ; rc = - EINVAL ; if ( ! tb [ SMC_PNETID_IBNAME ] ) goto error ; rc = - ENOENT ; ibname = ( char * ) nla_data ( tb [ SMC_PNETID_IBNAME ] ) ; ibname = strim ( ibname ) ; pnetelem -> smcibdev = smc_pnet_find_ib ( ibname ) ; if ( ! pnetelem -> smcibdev ) goto error ; rc = - EINVAL ; if ( ! tb [ SMC_PNETID_IBPORT ] ) goto error ; pnetelem -> ib_port = nla_get_u8 ( tb [ SMC_PNETID_IBPORT ] ) ; if ( pnetelem -> ib_port < 1 || pnetelem -> ib_port > SMC_MAX_PORTS ) goto error ; return 0 ; error : if ( pnetelem -> ndev ) dev_put ( pnetelem -> ndev ) ; return rc ; }
Parse the supplied netlink attributes and fill a pnetentry structure.
Parse the supplied netlink attributes and fill a pnetentry structure .