Re: [PATCH net-next v4 07/10] bridge: cfm: Netlink SET configuration Interface.

From: Jakub Kicinski
Date: Fri Oct 09 2020 - 22:03:35 EST


On Fri, 9 Oct 2020 14:35:27 +0000 Henrik Bjoernlund wrote:
> +static inline struct mac_addr nla_get_mac(const struct nlattr *nla)

static inlines are generally not needed in C sources and just hide
unused code. Please drop the inline annotation.

> +{
> + struct mac_addr mac;
> +
> + nla_memcpy(&mac.addr, nla, sizeof(mac.addr));
> +
> + return mac;
> +}
> +
> +static inline struct br_cfm_maid nla_get_maid(const struct nlattr *nla)

ditto

> +{
> + struct br_cfm_maid maid;
> +
> + nla_memcpy(&maid.data, nla, sizeof(maid.data));

returning a 48B struct from a helper is a little strange, but I guess
it's not too bad when compiler inlines the thing?

> + return maid;
> +}
> +
> +static const struct nla_policy
> +br_cfm_policy[IFLA_BRIDGE_CFM_MAX + 1] = {
> + [IFLA_BRIDGE_CFM_UNSPEC] = { .type = NLA_REJECT },

Not needed, REJECT is treated the same as 0 / uninit, right?

> + [IFLA_BRIDGE_CFM_MEP_CREATE] = { .type = NLA_NESTED },

Consider using NLA_POLICY_NESTED() to link up the next layers.

> + [IFLA_BRIDGE_CFM_MEP_DELETE] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_MEP_CONFIG] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_CONFIG] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_RDI] = { .type = NLA_NESTED },
> + [IFLA_BRIDGE_CFM_CC_CCM_TX] = { .type = NLA_NESTED },
> +};