Skip to content

Commit

Permalink
odp-util: Extract vxlan gbp option decoding to a function.
Browse files Browse the repository at this point in the history
Extract vxlan gbp option decoding to odp_decode_gbp_raw to be used in
following commits.

Reviewed-by: Roi Dayan <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: Gavin Li <[email protected]>
Signed-off-by: Eelco Chaudron <[email protected]>
  • Loading branch information
GavinLi-NV authored and chaudron committed Jul 3, 2023
1 parent affb9b8 commit 8c3d548
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3162,8 +3162,7 @@ odp_tun_key_from_attr__(const struct nlattr *attr, bool is_mask,
if (ext[OVS_VXLAN_EXT_GBP]) {
uint32_t gbp = nl_attr_get_u32(ext[OVS_VXLAN_EXT_GBP]);

tun->gbp_id = htons(gbp & 0xFFFF);
tun->gbp_flags = (gbp >> 16) & 0xFF;
odp_decode_gbp_raw(gbp, &tun->gbp_id, &tun->gbp_flags);
}

break;
Expand Down Expand Up @@ -3753,12 +3752,10 @@ format_odp_tun_vxlan_opt(const struct nlattr *attr,
ovs_be16 id, id_mask;
uint8_t flags, flags_mask = 0;

id = htons(key & 0xFFFF);
flags = (key >> 16) & 0xFF;
odp_decode_gbp_raw(key, &id, &flags);
if (ma) {
uint32_t mask = nl_attr_get_u32(ma);
id_mask = htons(mask & 0xFFFF);
flags_mask = (mask >> 16) & 0xFF;
odp_decode_gbp_raw(mask, &id_mask, &flags_mask);
}

ds_put_cstr(ds, "gbp(");
Expand Down
8 changes: 8 additions & 0 deletions lib/odp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,14 @@ void odp_put_push_eth_action(struct ofpbuf *odp_actions,
const struct eth_addr *eth_src,
const struct eth_addr *eth_dst);

static inline void odp_decode_gbp_raw(uint32_t gbp_raw,
ovs_be16 *id,
uint8_t *flags)
{
*id = htons(gbp_raw & 0xFFFF);
*flags = (gbp_raw >> 16) & 0xFF;
}

struct attr_len_tbl {
int len;
const struct attr_len_tbl *next;
Expand Down

0 comments on commit 8c3d548

Please sign in to comment.