On Fri, Nov 04, 2022 at 06:46:05AM +0000, Peng He wrote: > The tail of the struct dp_netdev_flow contains a whole netdev_flow_key > struct. > > We need to first minus the size of netdev_flow_key then add back > the real size of this netdev_flow_key.
Hi Peng, It seems to me that as a result of this change the space allocated for struct dp_netdev_flow will be truncated just before the cr.flow.mf field, rather than just before the cf.flow field. And that as a result space is allocated for the cr.flow.hash and cr.flow.len fields. But, based on the patch description, it is not clear to me why this change is being made. Perhaps it would be useful to add that information to the patch description. > Signed-off-by: Peng He <[email protected]> > --- > lib/dpif-netdev.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c > index 2c08a71c8..a8779a979 100644 > --- a/lib/dpif-netdev.c > +++ b/lib/dpif-netdev.c > @@ -4072,7 +4072,8 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, > && !FLOWMAP_HAS_FIELD(&mask.mf.map, regs)); > > /* Do not allocate extra space. */ > - flow = xmalloc(sizeof *flow - sizeof flow->cr.flow.mf + mask.len); > + flow = xmalloc(sizeof *flow - sizeof(flow->cr.flow) + > + offsetof(struct netdev_flow_key, mf) + mask.len); > memset(&flow->stats, 0, sizeof flow->stats); > atomic_init(&flow->netdev_flow_get_result, 0); > memset(&flow->last_stats, 0, sizeof flow->last_stats); > @@ -9744,7 +9745,8 @@ dpcls_create_subtable(struct dpcls *cls, const struct > netdev_flow_key *mask) > > /* Need to add one. */ > subtable = xmalloc(sizeof *subtable > - - sizeof subtable->mask.mf + mask->len); > + - sizeof subtable->mask > + + offsetof(struct netdev_flow_key, mf) + mask->len); > cmap_init(&subtable->rules); > subtable->hit_cnt = 0; > netdev_flow_key_clone(&subtable->mask, mask); > -- > 2.25.1 > > _______________________________________________ > dev mailing list > [email protected] > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
