Re: [ovs-dev] [PATCH 2/3] dpif-netlink-rtnl: Use getlink() in common verify path.
On 22 May 2017 at 10:40, Eric Garverwrote: > On Fri, May 19, 2017 at 01:27:35PM -0700, Joe Stringer wrote: >> The calls here were duplicated across each tunnel protocol. >> >> Signed-off-by: Joe Stringer >> --- >> lib/dpif-netlink-rtnl.c | 100 >> +--- >> 1 file changed, 43 insertions(+), 57 deletions(-) >> >> diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c >> index 0ca6529e9d82..76ab0fe3fdec 100644 >> --- a/lib/dpif-netlink-rtnl.c >> +++ b/lib/dpif-netlink-rtnl.c >> @@ -160,34 +160,23 @@ rtnl_policy_parse(const char *kind, struct ofpbuf >> *reply, >> >> static int >> dpif_netlink_rtnl_vxlan_verify(const struct netdev_tunnel_config *tnl_cfg, >> - const char *name, const char *kind) >> + const char *kind, struct ofpbuf *reply) >> { >> -struct ofpbuf *reply; >> +struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; >> int err; >> >> -err = dpif_netlink_rtnl_getlink(name, ); >> - >> +err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, >> +ARRAY_SIZE(vxlan_policy)); >> if (!err) { >> -struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; >> - >> -err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, >> -ARRAY_SIZE(vxlan_policy)); >> -if (!err) { >> -if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) >> -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) >> -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) >> -|| (tnl_cfg->dst_port >> -!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT]))) { >> -err = EINVAL; >> -} >> -} >> -if (!err) { >> -if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) >> -&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP])) { >> -err = EINVAL; >> -} >> +if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) >> +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) >> +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) >> +|| (tnl_cfg->dst_port >> +!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT])) >> +|| (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) >> +&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP]))) { >> +err = EINVAL; >> } >> -ofpbuf_delete(reply); >> } >> >> return err; >> @@ -195,24 +184,17 @@ dpif_netlink_rtnl_vxlan_verify(const struct >> netdev_tunnel_config *tnl_cfg, >> >> static int >> dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED >> *tnl, >> - const char *name, const char *kind) >> + const char *kind, struct ofpbuf *reply) >> { >> -struct ofpbuf *reply; >> +struct nlattr *gre[ARRAY_SIZE(gre_policy)]; >> int err; >> >> -err = dpif_netlink_rtnl_getlink(name, ); >> - >> +err = rtnl_policy_parse(kind, reply, gre_policy, gre, >> +ARRAY_SIZE(gre_policy)); >> if (!err) { >> -struct nlattr *gre[ARRAY_SIZE(gre_policy)]; >> - >> -err = rtnl_policy_parse(kind, reply, gre_policy, gre, >> -ARRAY_SIZE(gre_policy)); >> -if (!err) { >> -if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { >> -err = EINVAL; >> -} >> +if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { >> +err = EINVAL; >> } >> -ofpbuf_delete(reply); >> } >> >> return err; >> @@ -220,27 +202,20 @@ dpif_netlink_rtnl_gre_verify(const struct >> netdev_tunnel_config OVS_UNUSED *tnl, >> >> static int >> dpif_netlink_rtnl_geneve_verify(const struct netdev_tunnel_config *tnl_cfg, >> -const char *name, const char *kind) >> +const char *kind, struct ofpbuf *reply) >> { >> -struct ofpbuf *reply; >> +struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; >> int err; >> >> -err = dpif_netlink_rtnl_getlink(name, ); >> - >> +err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, >> +ARRAY_SIZE(geneve_policy)); >> if (!err) { >> -struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; >> - >> -err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, >> -ARRAY_SIZE(geneve_policy)); >> -if (!err) { >> -if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) >> -|| 1 != >> nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) >> -|| (tnl_cfg->dst_port >> -!= nl_attr_get_be16(geneve[IFLA_GENEVE_PORT]))) { >> -err = EINVAL; >> -} >> +
Re: [ovs-dev] [PATCH 2/3] dpif-netlink-rtnl: Use getlink() in common verify path.
On Fri, May 19, 2017 at 01:27:35PM -0700, Joe Stringer wrote: > The calls here were duplicated across each tunnel protocol. > > Signed-off-by: Joe Stringer> --- > lib/dpif-netlink-rtnl.c | 100 > +--- > 1 file changed, 43 insertions(+), 57 deletions(-) > > diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c > index 0ca6529e9d82..76ab0fe3fdec 100644 > --- a/lib/dpif-netlink-rtnl.c > +++ b/lib/dpif-netlink-rtnl.c > @@ -160,34 +160,23 @@ rtnl_policy_parse(const char *kind, struct ofpbuf > *reply, > > static int > dpif_netlink_rtnl_vxlan_verify(const struct netdev_tunnel_config *tnl_cfg, > - const char *name, const char *kind) > + const char *kind, struct ofpbuf *reply) > { > -struct ofpbuf *reply; > +struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; > int err; > > -err = dpif_netlink_rtnl_getlink(name, ); > - > +err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, > +ARRAY_SIZE(vxlan_policy)); > if (!err) { > -struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; > - > -err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, > -ARRAY_SIZE(vxlan_policy)); > -if (!err) { > -if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) > -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) > -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) > -|| (tnl_cfg->dst_port > -!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT]))) { > -err = EINVAL; > -} > -} > -if (!err) { > -if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) > -&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP])) { > -err = EINVAL; > -} > +if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) > +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) > +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) > +|| (tnl_cfg->dst_port > +!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT])) > +|| (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) > +&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP]))) { > +err = EINVAL; > } > -ofpbuf_delete(reply); > } > > return err; > @@ -195,24 +184,17 @@ dpif_netlink_rtnl_vxlan_verify(const struct > netdev_tunnel_config *tnl_cfg, > > static int > dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED > *tnl, > - const char *name, const char *kind) > + const char *kind, struct ofpbuf *reply) > { > -struct ofpbuf *reply; > +struct nlattr *gre[ARRAY_SIZE(gre_policy)]; > int err; > > -err = dpif_netlink_rtnl_getlink(name, ); > - > +err = rtnl_policy_parse(kind, reply, gre_policy, gre, > +ARRAY_SIZE(gre_policy)); > if (!err) { > -struct nlattr *gre[ARRAY_SIZE(gre_policy)]; > - > -err = rtnl_policy_parse(kind, reply, gre_policy, gre, > -ARRAY_SIZE(gre_policy)); > -if (!err) { > -if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { > -err = EINVAL; > -} > +if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { > +err = EINVAL; > } > -ofpbuf_delete(reply); > } > > return err; > @@ -220,27 +202,20 @@ dpif_netlink_rtnl_gre_verify(const struct > netdev_tunnel_config OVS_UNUSED *tnl, > > static int > dpif_netlink_rtnl_geneve_verify(const struct netdev_tunnel_config *tnl_cfg, > -const char *name, const char *kind) > +const char *kind, struct ofpbuf *reply) > { > -struct ofpbuf *reply; > +struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; > int err; > > -err = dpif_netlink_rtnl_getlink(name, ); > - > +err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, > +ARRAY_SIZE(geneve_policy)); > if (!err) { > -struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; > - > -err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, > -ARRAY_SIZE(geneve_policy)); > -if (!err) { > -if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) > -|| 1 != nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) > -|| (tnl_cfg->dst_port > -!= nl_attr_get_be16(geneve[IFLA_GENEVE_PORT]))) { > -err = EINVAL; > -} > +if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) > +|| 1 != nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) > +||
Re: [ovs-dev] [PATCH 2/3] dpif-netlink-rtnl: Use getlink() in common verify path.
On Fri, 2017-05-19 at 13:27 -0700, Joe Stringer wrote: > The calls here were duplicated across each tunnel protocol. > > Signed-off-by: Joe Stringer> --- > lib/dpif-netlink-rtnl.c | 100 > +--- > 1 file changed, 43 insertions(+), 57 deletions(-) > Acked-by: Greg Rose > diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c > index 0ca6529e9d82..76ab0fe3fdec 100644 > --- a/lib/dpif-netlink-rtnl.c > +++ b/lib/dpif-netlink-rtnl.c > @@ -160,34 +160,23 @@ rtnl_policy_parse(const char *kind, struct ofpbuf > *reply, > > static int > dpif_netlink_rtnl_vxlan_verify(const struct netdev_tunnel_config *tnl_cfg, > - const char *name, const char *kind) > + const char *kind, struct ofpbuf *reply) > { > -struct ofpbuf *reply; > +struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; > int err; > > -err = dpif_netlink_rtnl_getlink(name, ); > - > +err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, > +ARRAY_SIZE(vxlan_policy)); > if (!err) { > -struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; > - > -err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, > -ARRAY_SIZE(vxlan_policy)); > -if (!err) { > -if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) > -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) > -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) > -|| (tnl_cfg->dst_port > -!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT]))) { > -err = EINVAL; > -} > -} > -if (!err) { > -if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) > -&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP])) { > -err = EINVAL; > -} > +if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) > +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) > +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) > +|| (tnl_cfg->dst_port > +!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT])) > +|| (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) > +&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP]))) { > +err = EINVAL; > } > -ofpbuf_delete(reply); > } > > return err; > @@ -195,24 +184,17 @@ dpif_netlink_rtnl_vxlan_verify(const struct > netdev_tunnel_config *tnl_cfg, > > static int > dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED > *tnl, > - const char *name, const char *kind) > + const char *kind, struct ofpbuf *reply) > { > -struct ofpbuf *reply; > +struct nlattr *gre[ARRAY_SIZE(gre_policy)]; > int err; > > -err = dpif_netlink_rtnl_getlink(name, ); > - > +err = rtnl_policy_parse(kind, reply, gre_policy, gre, > +ARRAY_SIZE(gre_policy)); > if (!err) { > -struct nlattr *gre[ARRAY_SIZE(gre_policy)]; > - > -err = rtnl_policy_parse(kind, reply, gre_policy, gre, > -ARRAY_SIZE(gre_policy)); > -if (!err) { > -if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { > -err = EINVAL; > -} > +if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { > +err = EINVAL; > } > -ofpbuf_delete(reply); > } > > return err; > @@ -220,27 +202,20 @@ dpif_netlink_rtnl_gre_verify(const struct > netdev_tunnel_config OVS_UNUSED *tnl, > > static int > dpif_netlink_rtnl_geneve_verify(const struct netdev_tunnel_config *tnl_cfg, > -const char *name, const char *kind) > +const char *kind, struct ofpbuf *reply) > { > -struct ofpbuf *reply; > +struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; > int err; > > -err = dpif_netlink_rtnl_getlink(name, ); > - > +err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, > +ARRAY_SIZE(geneve_policy)); > if (!err) { > -struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; > - > -err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, > -ARRAY_SIZE(geneve_policy)); > -if (!err) { > -if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) > -|| 1 != nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) > -|| (tnl_cfg->dst_port > -!= nl_attr_get_be16(geneve[IFLA_GENEVE_PORT]))) { > -err = EINVAL; > -} > +if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) > +|| 1 !=
[ovs-dev] [PATCH 2/3] dpif-netlink-rtnl: Use getlink() in common verify path.
The calls here were duplicated across each tunnel protocol. Signed-off-by: Joe Stringer--- lib/dpif-netlink-rtnl.c | 100 +--- 1 file changed, 43 insertions(+), 57 deletions(-) diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c index 0ca6529e9d82..76ab0fe3fdec 100644 --- a/lib/dpif-netlink-rtnl.c +++ b/lib/dpif-netlink-rtnl.c @@ -160,34 +160,23 @@ rtnl_policy_parse(const char *kind, struct ofpbuf *reply, static int dpif_netlink_rtnl_vxlan_verify(const struct netdev_tunnel_config *tnl_cfg, - const char *name, const char *kind) + const char *kind, struct ofpbuf *reply) { -struct ofpbuf *reply; +struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; int err; -err = dpif_netlink_rtnl_getlink(name, ); - +err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, +ARRAY_SIZE(vxlan_policy)); if (!err) { -struct nlattr *vxlan[ARRAY_SIZE(vxlan_policy)]; - -err = rtnl_policy_parse(kind, reply, vxlan_policy, vxlan, -ARRAY_SIZE(vxlan_policy)); -if (!err) { -if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) -|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) -|| (tnl_cfg->dst_port -!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT]))) { -err = EINVAL; -} -} -if (!err) { -if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) -&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP])) { -err = EINVAL; -} +if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING]) +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA]) +|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) +|| (tnl_cfg->dst_port +!= nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT])) +|| (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP) +&& !nl_attr_get_flag(vxlan[IFLA_VXLAN_GBP]))) { +err = EINVAL; } -ofpbuf_delete(reply); } return err; @@ -195,24 +184,17 @@ dpif_netlink_rtnl_vxlan_verify(const struct netdev_tunnel_config *tnl_cfg, static int dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED *tnl, - const char *name, const char *kind) + const char *kind, struct ofpbuf *reply) { -struct ofpbuf *reply; +struct nlattr *gre[ARRAY_SIZE(gre_policy)]; int err; -err = dpif_netlink_rtnl_getlink(name, ); - +err = rtnl_policy_parse(kind, reply, gre_policy, gre, +ARRAY_SIZE(gre_policy)); if (!err) { -struct nlattr *gre[ARRAY_SIZE(gre_policy)]; - -err = rtnl_policy_parse(kind, reply, gre_policy, gre, -ARRAY_SIZE(gre_policy)); -if (!err) { -if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { -err = EINVAL; -} +if (!nl_attr_get_flag(gre[IFLA_GRE_COLLECT_METADATA])) { +err = EINVAL; } -ofpbuf_delete(reply); } return err; @@ -220,27 +202,20 @@ dpif_netlink_rtnl_gre_verify(const struct netdev_tunnel_config OVS_UNUSED *tnl, static int dpif_netlink_rtnl_geneve_verify(const struct netdev_tunnel_config *tnl_cfg, -const char *name, const char *kind) +const char *kind, struct ofpbuf *reply) { -struct ofpbuf *reply; +struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; int err; -err = dpif_netlink_rtnl_getlink(name, ); - +err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, +ARRAY_SIZE(geneve_policy)); if (!err) { -struct nlattr *geneve[ARRAY_SIZE(geneve_policy)]; - -err = rtnl_policy_parse(kind, reply, geneve_policy, geneve, -ARRAY_SIZE(geneve_policy)); -if (!err) { -if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) -|| 1 != nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) -|| (tnl_cfg->dst_port -!= nl_attr_get_be16(geneve[IFLA_GENEVE_PORT]))) { -err = EINVAL; -} +if (!nl_attr_get_flag(geneve[IFLA_GENEVE_COLLECT_METADATA]) +|| 1 != nl_attr_get_u8(geneve[IFLA_GENEVE_UDP_ZERO_CSUM6_RX]) +|| (tnl_cfg->dst_port +!= nl_attr_get_be16(geneve[IFLA_GENEVE_PORT]))) { +err = EINVAL; } -ofpbuf_delete(reply); } return err; @@ -250,20 +225,30 @@ static int dpif_netlink_rtnl_verify(const struct netdev_tunnel_config *tnl_cfg, enum