From 69685a8882e40d846f7bcdbb6a55d3cce517cc26 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Sat, 22 Oct 2011 18:22:18 -0700 Subject: [PATCH] datapath: Define constants for versions of GENL families. Currently we hard code the versions of our GENL families to 1 but it's nicer to have symbolic constants. Signed-off-by: Jesse Gross Acked-by: Ben Pfaff --- datapath/datapath.c | 8 ++++---- include/linux/openvswitch.h | 4 ++++ lib/dpif-linux.c | 9 +++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index de2f76b0..11a2a110 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -348,7 +348,7 @@ static struct genl_family dp_packet_genl_family = { .id = GENL_ID_GENERATE, .hdrsize = sizeof(struct ovs_header), .name = OVS_PACKET_FAMILY, - .version = 1, + .version = OVS_PACKET_VERSION, .maxattr = OVS_PACKET_ATTR_MAX }; @@ -863,7 +863,7 @@ static struct genl_family dp_flow_genl_family = { .id = GENL_ID_GENERATE, .hdrsize = sizeof(struct ovs_header), .name = OVS_FLOW_FAMILY, - .version = 1, + .version = OVS_FLOW_VERSION, .maxattr = OVS_FLOW_ATTR_MAX }; @@ -1252,7 +1252,7 @@ static struct genl_family dp_datapath_genl_family = { .id = GENL_ID_GENERATE, .hdrsize = sizeof(struct ovs_header), .name = OVS_DATAPATH_FAMILY, - .version = 1, + .version = OVS_DATAPATH_VERSION, .maxattr = OVS_DP_ATTR_MAX }; @@ -1589,7 +1589,7 @@ static struct genl_family dp_vport_genl_family = { .id = GENL_ID_GENERATE, .hdrsize = sizeof(struct ovs_header), .name = OVS_VPORT_FAMILY, - .version = 1, + .version = OVS_VPORT_VERSION, .maxattr = OVS_VPORT_ATTR_MAX }; diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h index 190bf79e..5bfe4886 100644 --- a/include/linux/openvswitch.h +++ b/include/linux/openvswitch.h @@ -46,6 +46,7 @@ #define OVS_DATAPATH_FAMILY "ovs_datapath" #define OVS_DATAPATH_MCGROUP "ovs_datapath" +#define OVS_DATAPATH_VERSION 0x1 enum ovs_datapath_cmd { OVS_DP_CMD_UNSPEC, @@ -116,6 +117,7 @@ struct ovs_vport_stats { #define OVSP_LOCAL ((__u16)0) #define OVS_PACKET_FAMILY "ovs_packet" +#define OVS_PACKET_VERSION 0x1 enum ovs_packet_cmd { OVS_PACKET_CMD_UNSPEC, @@ -173,6 +175,7 @@ enum ovs_vport_type { #define OVS_VPORT_FAMILY "ovs_vport" #define OVS_VPORT_MCGROUP "ovs_vport" +#define OVS_VPORT_VERSION 0x1 enum ovs_vport_cmd { OVS_VPORT_CMD_UNSPEC, @@ -238,6 +241,7 @@ enum { #define OVS_FLOW_FAMILY "ovs_flow" #define OVS_FLOW_MCGROUP "ovs_flow" +#define OVS_FLOW_VERSION 0x1 enum ovs_flow_cmd { OVS_FLOW_CMD_UNSPEC, diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 2466f915..c5628b7e 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -832,7 +832,7 @@ dpif_linux_encode_execute(int dp_ifindex, buf = ofpbuf_new(128 + actions_len + packet->size); nl_msg_put_genlmsghdr(buf, 0, ovs_packet_family, NLM_F_REQUEST, - OVS_PACKET_CMD_EXECUTE, 1); + OVS_PACKET_CMD_EXECUTE, OVS_PACKET_VERSION); execute = ofpbuf_put_uninit(buf, sizeof *execute); execute->dp_ifindex = dp_ifindex; @@ -1389,7 +1389,7 @@ dpif_linux_vport_to_ofpbuf(const struct dpif_linux_vport *vport, struct ovs_header *ovs_header; nl_msg_put_genlmsghdr(buf, 0, ovs_vport_family, NLM_F_REQUEST | NLM_F_ECHO, - vport->cmd, 1); + vport->cmd, OVS_VPORT_VERSION); ovs_header = ofpbuf_put_uninit(buf, sizeof *ovs_header); ovs_header->dp_ifindex = vport->dp_ifindex; @@ -1549,7 +1549,8 @@ dpif_linux_dp_to_ofpbuf(const struct dpif_linux_dp *dp, struct ofpbuf *buf) struct ovs_header *ovs_header; nl_msg_put_genlmsghdr(buf, 0, ovs_datapath_family, - NLM_F_REQUEST | NLM_F_ECHO, dp->cmd, 1); + NLM_F_REQUEST | NLM_F_ECHO, dp->cmd, + OVS_DATAPATH_VERSION); ovs_header = ofpbuf_put_uninit(buf, sizeof *ovs_header); ovs_header->dp_ifindex = dp->dp_ifindex; @@ -1708,7 +1709,7 @@ dpif_linux_flow_to_ofpbuf(const struct dpif_linux_flow *flow, nl_msg_put_genlmsghdr(buf, 0, ovs_flow_family, NLM_F_REQUEST | flow->nlmsg_flags, - flow->cmd, 1); + flow->cmd, OVS_FLOW_VERSION); ovs_header = ofpbuf_put_uninit(buf, sizeof *ovs_header); ovs_header->dp_ifindex = flow->dp_ifindex; -- 2.30.2