openvswitch: Simplify interface ovs_flow_metadata_from_nlattrs()
This is not functional change, this is just code cleanup. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
This commit is contained in:
parent
b34df5e805
commit
93d8fd1514
@ -739,10 +739,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
|
|||||||
if (err)
|
if (err)
|
||||||
goto err_flow_free;
|
goto err_flow_free;
|
||||||
|
|
||||||
err = ovs_flow_metadata_from_nlattrs(&flow->key.phy.priority,
|
err = ovs_flow_metadata_from_nlattrs(flow, a[OVS_PACKET_ATTR_KEY]);
|
||||||
&flow->key.phy.skb_mark,
|
|
||||||
&flow->key.phy.in_port,
|
|
||||||
a[OVS_PACKET_ATTR_KEY]);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto err_flow_free;
|
goto err_flow_free;
|
||||||
|
|
||||||
|
@ -1125,10 +1125,8 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key.
|
* ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key.
|
||||||
* @priority: receives the skb priority
|
* @flow: Receives extracted in_port, priority, tun_key and skb_mark.
|
||||||
* @mark: receives the skb mark
|
* @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
|
||||||
* @in_port: receives the extracted input port.
|
|
||||||
* @key: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
|
|
||||||
* sequence.
|
* sequence.
|
||||||
*
|
*
|
||||||
* This parses a series of Netlink attributes that form a flow key, which must
|
* This parses a series of Netlink attributes that form a flow key, which must
|
||||||
@ -1136,15 +1134,15 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
|
|||||||
* get the metadata, that is, the parts of the flow key that cannot be
|
* get the metadata, that is, the parts of the flow key that cannot be
|
||||||
* extracted from the packet itself.
|
* extracted from the packet itself.
|
||||||
*/
|
*/
|
||||||
int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,
|
int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
|
||||||
const struct nlattr *attr)
|
const struct nlattr *attr)
|
||||||
{
|
{
|
||||||
const struct nlattr *nla;
|
const struct nlattr *nla;
|
||||||
int rem;
|
int rem;
|
||||||
|
|
||||||
*in_port = DP_MAX_PORTS;
|
flow->key.phy.in_port = DP_MAX_PORTS;
|
||||||
*priority = 0;
|
flow->key.phy.priority = 0;
|
||||||
*mark = 0;
|
flow->key.phy.skb_mark = 0;
|
||||||
|
|
||||||
nla_for_each_nested(nla, attr, rem) {
|
nla_for_each_nested(nla, attr, rem) {
|
||||||
int type = nla_type(nla);
|
int type = nla_type(nla);
|
||||||
@ -1155,17 +1153,17 @@ int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OVS_KEY_ATTR_PRIORITY:
|
case OVS_KEY_ATTR_PRIORITY:
|
||||||
*priority = nla_get_u32(nla);
|
flow->key.phy.priority = nla_get_u32(nla);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OVS_KEY_ATTR_IN_PORT:
|
case OVS_KEY_ATTR_IN_PORT:
|
||||||
if (nla_get_u32(nla) >= DP_MAX_PORTS)
|
if (nla_get_u32(nla) >= DP_MAX_PORTS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
*in_port = nla_get_u32(nla);
|
flow->key.phy.in_port = nla_get_u32(nla);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OVS_KEY_ATTR_SKB_MARK:
|
case OVS_KEY_ATTR_SKB_MARK:
|
||||||
*mark = nla_get_u32(nla);
|
flow->key.phy.skb_mark = nla_get_u32(nla);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies);
|
|||||||
int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);
|
int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);
|
||||||
int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
|
int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
|
||||||
const struct nlattr *);
|
const struct nlattr *);
|
||||||
int ovs_flow_metadata_from_nlattrs(u32 *priority, u32 *mark, u16 *in_port,
|
int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
|
||||||
const struct nlattr *);
|
const struct nlattr *attr);
|
||||||
|
|
||||||
#define MAX_ACTIONS_BUFSIZE (16 * 1024)
|
#define MAX_ACTIONS_BUFSIZE (16 * 1024)
|
||||||
#define TBL_MIN_BUCKETS 1024
|
#define TBL_MIN_BUCKETS 1024
|
||||||
|
Loading…
Reference in New Issue
Block a user