From: Ben Pfaff Date: Wed, 12 Oct 2011 18:04:10 +0000 (-0700) Subject: datapath: Require explicit upcall_pid for new datapaths and vports. X-Git-Tag: v1.3.0~114 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ea36840fa4d6e9ce1e29fa8ce148edd3caef0072;p=sliver-openvswitch.git datapath: Require explicit upcall_pid for new datapaths and vports. This increases consistency with the OVS_ACTION_ATTR_USERSPACE action, which also requires an explicit pid. Suggested-by: Jesse Gross Signed-off-by: Ben Pfaff Acked-by: Jesse Gross --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 551b384ad..950bed1b7 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -1282,7 +1282,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) int err; err = -EINVAL; - if (!a[OVS_DP_ATTR_NAME]) + if (!a[OVS_DP_ATTR_NAME] || !a[OVS_DP_ATTR_UPCALL_PID]) goto err; err = ovs_dp_cmd_validate(a); @@ -1326,10 +1326,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) parms.options = NULL; parms.dp = dp; parms.port_no = OVSP_LOCAL; - if (a[OVS_DP_ATTR_UPCALL_PID]) - parms.upcall_pid = nla_get_u32(a[OVS_DP_ATTR_UPCALL_PID]); - else - parms.upcall_pid = NETLINK_CB(skb).pid; + parms.upcall_pid = nla_get_u32(a[OVS_DP_ATTR_UPCALL_PID]); vport = new_vport(&parms); if (IS_ERR(vport)) { @@ -1664,7 +1661,8 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) int err; err = -EINVAL; - if (!a[OVS_VPORT_ATTR_NAME] || !a[OVS_VPORT_ATTR_TYPE]) + if (!a[OVS_VPORT_ATTR_NAME] || !a[OVS_VPORT_ATTR_TYPE] || + !a[OVS_VPORT_ATTR_UPCALL_PID]) goto exit; err = ovs_vport_cmd_validate(a); @@ -1705,10 +1703,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) parms.options = a[OVS_VPORT_ATTR_OPTIONS]; parms.dp = dp; parms.port_no = port_no; - if (a[OVS_VPORT_ATTR_UPCALL_PID]) - parms.upcall_pid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]); - else - parms.upcall_pid = NETLINK_CB(skb).pid; + parms.upcall_pid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]); vport = new_vport(&parms); err = PTR_ERR(vport); diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 1e1afe50a..08ac4425b 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -235,6 +235,7 @@ dpif_linux_open(const struct dpif_class *class OVS_UNUSED, const char *name, { struct dpif_linux_dp dp_request, dp; struct ofpbuf *buf; + uint32_t upcall_pid; int error; error = dpif_linux_init(); @@ -244,7 +245,13 @@ dpif_linux_open(const struct dpif_class *class OVS_UNUSED, const char *name, /* Create or look up datapath. */ dpif_linux_dp_init(&dp_request); - dp_request.cmd = create ? OVS_DP_CMD_NEW : OVS_DP_CMD_GET; + if (create) { + dp_request.cmd = OVS_DP_CMD_NEW; + upcall_pid = 0; + dp_request.upcall_pid = &upcall_pid; + } else { + dp_request.cmd = OVS_DP_CMD_GET; + } dp_request.name = name; error = dpif_linux_dp_transact(&dp_request, &dp, &buf); if (error) {