Commit 6182d587 authored by Daniel Machon's avatar Daniel Machon Committed by Paolo Abeni

net: dcb: add new apptrust attribute

Add new apptrust extension attributes to the 8021Qaz APP managed object.

Two new attributes, DCB_ATTR_DCB_APP_TRUST_TABLE and
DCB_ATTR_DCB_APP_TRUST, has been added. Trusted selectors are passed in
the nested attribute DCB_ATTR_DCB_APP_TRUST, in order of precedence.

The new attributes are meant to allow drivers, whose hw supports the
notion of trust, to be able to set whether a particular app selector is
trusted - and in which order.
Signed-off-by: default avatarDaniel Machon <daniel.machon@microchip.com>
Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent ec32c0c4
...@@ -109,6 +109,10 @@ struct dcbnl_rtnl_ops { ...@@ -109,6 +109,10 @@ struct dcbnl_rtnl_ops {
/* buffer settings */ /* buffer settings */
int (*dcbnl_getbuffer)(struct net_device *, struct dcbnl_buffer *); int (*dcbnl_getbuffer)(struct net_device *, struct dcbnl_buffer *);
int (*dcbnl_setbuffer)(struct net_device *, struct dcbnl_buffer *); int (*dcbnl_setbuffer)(struct net_device *, struct dcbnl_buffer *);
/* apptrust */
int (*dcbnl_setapptrust)(struct net_device *, u8 *, int);
int (*dcbnl_getapptrust)(struct net_device *, u8 *, int *);
}; };
#endif /* __NET_DCBNL_H__ */ #endif /* __NET_DCBNL_H__ */
...@@ -410,6 +410,7 @@ enum dcbnl_attrs { ...@@ -410,6 +410,7 @@ enum dcbnl_attrs {
* @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only * @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only
* @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only * @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only
* @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only * @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only
* @DCB_ATTR_DCB_APP_TRUST_TABLE: selector trust table
*/ */
enum ieee_attrs { enum ieee_attrs {
DCB_ATTR_IEEE_UNSPEC, DCB_ATTR_IEEE_UNSPEC,
...@@ -423,6 +424,7 @@ enum ieee_attrs { ...@@ -423,6 +424,7 @@ enum ieee_attrs {
DCB_ATTR_IEEE_QCN, DCB_ATTR_IEEE_QCN,
DCB_ATTR_IEEE_QCN_STATS, DCB_ATTR_IEEE_QCN_STATS,
DCB_ATTR_DCB_BUFFER, DCB_ATTR_DCB_BUFFER,
DCB_ATTR_DCB_APP_TRUST_TABLE,
__DCB_ATTR_IEEE_MAX __DCB_ATTR_IEEE_MAX
}; };
#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1) #define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
......
...@@ -166,6 +166,7 @@ static const struct nla_policy dcbnl_ieee_policy[DCB_ATTR_IEEE_MAX + 1] = { ...@@ -166,6 +166,7 @@ static const struct nla_policy dcbnl_ieee_policy[DCB_ATTR_IEEE_MAX + 1] = {
[DCB_ATTR_IEEE_QCN] = {.len = sizeof(struct ieee_qcn)}, [DCB_ATTR_IEEE_QCN] = {.len = sizeof(struct ieee_qcn)},
[DCB_ATTR_IEEE_QCN_STATS] = {.len = sizeof(struct ieee_qcn_stats)}, [DCB_ATTR_IEEE_QCN_STATS] = {.len = sizeof(struct ieee_qcn_stats)},
[DCB_ATTR_DCB_BUFFER] = {.len = sizeof(struct dcbnl_buffer)}, [DCB_ATTR_DCB_BUFFER] = {.len = sizeof(struct dcbnl_buffer)},
[DCB_ATTR_DCB_APP_TRUST_TABLE] = {.type = NLA_NESTED},
}; };
/* DCB number of traffic classes nested attributes. */ /* DCB number of traffic classes nested attributes. */
...@@ -1062,9 +1063,9 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, ...@@ -1062,9 +1063,9 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
/* Handle IEEE 802.1Qaz/802.1Qau/802.1Qbb GET commands. */ /* Handle IEEE 802.1Qaz/802.1Qau/802.1Qbb GET commands. */
static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
{ {
struct nlattr *ieee, *app;
struct dcb_app_type *itr;
const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
struct nlattr *ieee, *app, *apptrust;
struct dcb_app_type *itr;
int dcbx; int dcbx;
int err; int err;
...@@ -1166,6 +1167,30 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) ...@@ -1166,6 +1167,30 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
spin_unlock_bh(&dcb_lock); spin_unlock_bh(&dcb_lock);
nla_nest_end(skb, app); nla_nest_end(skb, app);
if (ops->dcbnl_getapptrust) {
u8 selectors[IEEE_8021QAZ_APP_SEL_MAX + 1] = {0};
int nselectors, i;
apptrust = nla_nest_start(skb, DCB_ATTR_DCB_APP_TRUST_TABLE);
if (!apptrust)
return -EMSGSIZE;
err = ops->dcbnl_getapptrust(netdev, selectors, &nselectors);
if (!err) {
for (i = 0; i < nselectors; i++) {
enum ieee_attrs_app type =
dcbnl_app_attr_type_get(selectors[i]);
err = nla_put_u8(skb, type, selectors[i]);
if (err) {
nla_nest_cancel(skb, apptrust);
return err;
}
}
}
nla_nest_end(skb, apptrust);
}
/* get peer info if available */ /* get peer info if available */
if (ops->ieee_peer_getets) { if (ops->ieee_peer_getets) {
struct ieee_ets ets; struct ieee_ets ets;
...@@ -1554,6 +1579,53 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh, ...@@ -1554,6 +1579,53 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh,
} }
} }
if (ieee[DCB_ATTR_DCB_APP_TRUST_TABLE]) {
u8 selectors[IEEE_8021QAZ_APP_SEL_MAX + 1] = {0};
struct nlattr *attr;
int nselectors = 0;
int rem;
if (!ops->dcbnl_setapptrust) {
err = -EOPNOTSUPP;
goto err;
}
nla_for_each_nested(attr, ieee[DCB_ATTR_DCB_APP_TRUST_TABLE],
rem) {
enum ieee_attrs_app type = nla_type(attr);
u8 selector;
int i;
if (!dcbnl_app_attr_type_validate(type) ||
nla_len(attr) != 1 ||
nselectors >= sizeof(selectors)) {
err = -EINVAL;
goto err;
}
selector = nla_get_u8(attr);
if (!dcbnl_app_selector_validate(type, selector)) {
err = -EINVAL;
goto err;
}
/* Duplicate selector ? */
for (i = 0; i < nselectors; i++) {
if (selectors[i] == selector) {
err = -EINVAL;
goto err;
}
}
selectors[nselectors++] = selector;
}
err = ops->dcbnl_setapptrust(netdev, selectors, nselectors);
if (err)
goto err;
}
err: err:
err = nla_put_u8(skb, DCB_ATTR_IEEE, err); err = nla_put_u8(skb, DCB_ATTR_IEEE, err);
dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0); dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment