There have been multiple definitions of the put_load() function through out the code base. There have also been variation of put_load that allows to set BE array instead of LE constant. Move both variations to ovn-util and djust the code as needed.
Signed-off-by: Ales Musil <amu...@redhat.com> --- controller/lflow.c | 51 +++++++------------------------------------ controller/physical.c | 12 ---------- controller/pinctrl.c | 16 -------------- lib/actions.c | 12 ---------- lib/ovn-util.c | 19 ++++++++++++++++ lib/ovn-util.h | 6 +++++ 6 files changed, 33 insertions(+), 83 deletions(-) diff --git a/controller/lflow.c b/controller/lflow.c index 04d7748fe..e97162c23 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -1293,30 +1293,6 @@ consider_logical_flow(const struct sbrec_logical_flow *lflow, } } -static void -put_load(const uint8_t *data, size_t len, - enum mf_field_id dst, int ofs, int n_bits, - struct ofpbuf *ofpacts) -{ - struct ofpact_set_field *sf = ofpact_put_set_field(ofpacts, - mf_from_id(dst), NULL, - NULL); - bitwise_copy(data, len, 0, sf->value, sf->field->n_bytes, ofs, n_bits); - bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); -} - -static void -put_load64(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, - struct ofpbuf *ofpacts) -{ - struct ofpact_set_field *sf = ofpact_put_set_field(ofpacts, - mf_from_id(dst), NULL, - NULL); - ovs_be64 n_value = htonll(value); - bitwise_copy(&n_value, 8, 0, sf->value, sf->field->n_bytes, ofs, n_bits); - bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); -} - static void consider_neighbor_flow(struct ovsdb_idl_index *sbrec_port_binding_by_name, const struct hmap *local_datapaths, @@ -1409,18 +1385,15 @@ consider_neighbor_flow(struct ovsdb_idl_index *sbrec_port_binding_by_name, uint64_t stub[1024 / 8]; struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(stub); - uint8_t value = 1; - put_load(mac_addr.ea, sizeof mac_addr.ea, MFF_ETH_DST, 0, 48, &ofpacts); - put_load(&value, sizeof value, MFF_LOG_FLAGS, MLF_LOOKUP_MAC_BIT, 1, - &ofpacts); + put_load_be(mac_addr.ea, sizeof mac_addr.ea, MFF_ETH_DST, 0, 48, &ofpacts); + put_load(1, MFF_LOG_FLAGS, MLF_LOOKUP_MAC_BIT, 1, &ofpacts); ofctrl_add_flow(flow_table, OFTABLE_MAC_BINDING, priority, b ? b->header_.uuid.parts[0] : smb->header_.uuid.parts[0], &get_arp_match, &ofpacts, b ? &b->header_.uuid : &smb->header_.uuid); ofpbuf_clear(&ofpacts); - put_load(&value, sizeof value, MFF_LOG_FLAGS, MLF_LOOKUP_MAC_BIT, 1, - &ofpacts); + put_load(1, MFF_LOG_FLAGS, MLF_LOOKUP_MAC_BIT, 1, &ofpacts); ofctrl_add_flow(flow_table, OFTABLE_MAC_LOOKUP, priority, b ? b->header_.uuid.parts[0] : smb->header_.uuid.parts[0], &lookup_arp_match, &ofpacts, @@ -1663,9 +1636,7 @@ add_lb_vip_hairpin_flows(const struct ovn_controller_lb *lb, struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(stub); struct match hairpin_match = MATCH_CATCHALL_INITIALIZER; - uint8_t value = 1; - put_load(&value, sizeof value, MFF_LOG_FLAGS, - MLF_LOOKUP_LB_HAIRPIN_BIT, 1, &ofpacts); + put_load(1, MFF_LOG_FLAGS, MLF_LOOKUP_LB_HAIRPIN_BIT, 1, &ofpacts); if (IN6_IS_ADDR_V4MAPPED(&lb_vip->vip)) { ovs_be32 bip4 = in6_addr_get_mapped_ipv4(&lb_backend->ip); @@ -2057,16 +2028,14 @@ consider_fdb_flows(const struct sbrec_fdb *fdb, uint64_t stub[1024 / 8]; struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(stub); - put_load64(fdb->port_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts); + put_load(fdb->port_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts); ofctrl_add_flow(flow_table, OFTABLE_GET_FDB, 100, fdb->header_.uuid.parts[0], &match, &ofpacts, &fdb->header_.uuid); ofpbuf_clear(&ofpacts); - uint8_t value = 1; uint8_t is_vif = pb ? !strcmp(pb->type, "") : 0; - put_load(&value, sizeof value, MFF_LOG_FLAGS, - MLF_LOOKUP_FDB_BIT, 1, &ofpacts); + put_load(1, MFF_LOG_FLAGS, MLF_LOOKUP_FDB_BIT, 1, &ofpacts); struct match lookup_match = MATCH_CATCHALL_INITIALIZER; match_set_metadata(&lookup_match, htonll(fdb->dp_key)); @@ -2458,17 +2427,13 @@ reset_match_for_port_sec_flows(const struct sbrec_port_binding *pb, static void build_port_sec_deny_action(struct ofpbuf *ofpacts) { ofpbuf_clear(ofpacts); - uint8_t value = 1; - put_load(&value, sizeof value, MFF_LOG_FLAGS, - MLF_CHECK_PORT_SEC_BIT, 1, ofpacts); + put_load(1, MFF_LOG_FLAGS, MLF_CHECK_PORT_SEC_BIT, 1, ofpacts); } static void build_port_sec_allow_action(struct ofpbuf *ofpacts) { ofpbuf_clear(ofpacts); - uint8_t value = 0; - put_load(&value, sizeof value, MFF_LOG_FLAGS, - MLF_CHECK_PORT_SEC_BIT, 1, ofpacts); + put_load(0, MFF_LOG_FLAGS, MLF_CHECK_PORT_SEC_BIT, 1, ofpacts); } static void build_port_sec_adv_nd_check(struct ofpbuf *ofpacts) diff --git a/controller/physical.c b/controller/physical.c index 15209318b..c5f74010a 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -96,18 +96,6 @@ physical_register_ovs_idl(struct ovsdb_idl *ovs_idl) ovsdb_idl_track_add_column(ovs_idl, &ovsrec_interface_col_external_ids); } -static void -put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, - struct ofpbuf *ofpacts) -{ - struct ofpact_set_field *sf = ofpact_put_set_field(ofpacts, - mf_from_id(dst), NULL, - NULL); - ovs_be64 n_value = htonll(value); - bitwise_copy(&n_value, 8, 0, sf->value, sf->field->n_bytes, ofs, n_bits); - bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); -} - static void put_move(enum mf_field_id src, int src_ofs, enum mf_field_id dst, int dst_ofs, diff --git a/controller/pinctrl.c b/controller/pinctrl.c index d4f4da731..68042a820 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -346,10 +346,6 @@ static void pinctrl_compose_ipv6(struct dp_packet *packet, uint8_t ip_proto, uint8_t ttl, uint16_t ip_payload_len); -static void -put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, - struct ofpbuf *ofpacts); - static void notify_pinctrl_main(void); static void notify_pinctrl_handler(void); @@ -4268,18 +4264,6 @@ ipv6_ra_calc_next_announce(time_t min_interval, time_t max_interval) random_range(max_interval_ms - min_interval_ms); } -static void -put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, - struct ofpbuf *ofpacts) -{ - struct ofpact_set_field *sf = ofpact_put_set_field(ofpacts, - mf_from_id(dst), NULL, - NULL); - ovs_be64 n_value = htonll(value); - bitwise_copy(&n_value, 8, 0, sf->value, sf->field->n_bytes, ofs, n_bits); - bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); -} - static void packet_put_ra_rdnss_opt(struct dp_packet *b, uint8_t num, ovs_be32 lifetime, const struct in6_addr *dns) diff --git a/lib/actions.c b/lib/actions.c index fa8aa20c2..00e439285 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -199,18 +199,6 @@ encode_restore_args(const struct arg args[], size_t n_args, } } -static void -put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, - struct ofpbuf *ofpacts) -{ - struct ofpact_set_field *sf = ofpact_put_set_field(ofpacts, - mf_from_id(dst), NULL, - NULL); - ovs_be64 n_value = htonll(value); - bitwise_copy(&n_value, 8, 0, sf->value, sf->field->n_bytes, ofs, n_bits); - bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); -} - static uint8_t first_ptable(const struct ovnact_encode_params *ep, enum ovnact_pipeline pipeline) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index d7e236059..c8d10f493 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -1484,3 +1484,22 @@ ovn_mirror_port_name(const char *datapath_name, { return xasprintf("mp-%s-%s", datapath_name, port_name); } + +void +put_load_be(const void *value, size_t len, enum mf_field_id dst, + size_t ofs, size_t n_bits, struct ofpbuf *ofpacts) +{ + struct ofpact_set_field *sf = ofpact_put_set_field(ofpacts, + mf_from_id(dst), NULL, + NULL); + bitwise_copy(value, len, 0, sf->value, sf->field->n_bytes, ofs, n_bits); + bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); +} + +void +put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, + struct ofpbuf *ofpacts) +{ + ovs_be64 n_value = htonll(value); + put_load_be(&n_value, 8, dst, ofs, n_bits, ofpacts); +} diff --git a/lib/ovn-util.h b/lib/ovn-util.h index c05bfc53b..eddb07f4d 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -16,6 +16,7 @@ #ifndef OVN_UTIL_H #define OVN_UTIL_H 1 +#include "openvswitch/meta-flow.h" #include "ovsdb-idl.h" #include "lib/packets.h" #include "lib/sset.h" @@ -504,6 +505,11 @@ const struct sbrec_port_binding *lport_lookup_by_name( struct ovsdb_idl_index *sbrec_port_binding_by_name, const char *name); +void put_load_be(const void *value, size_t len, enum mf_field_id dst, + size_t ofs, size_t n_bits, struct ofpbuf *ofpacts); +void put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, + struct ofpbuf *ofpacts); + /* __NARG__ provides a way to count the number of arguments passed to a * variadic macro. As defined below, it's capable of counting up to * 16 arguments. This should be more than enough for our purposes. However -- 2.50.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev