On Fri, Nov 4, 2022 at 2:46 AM Peng He <xnhp0...@gmail.com> 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. > > Signed-off-by: Peng He <xnhp0...@gmail.com> > --- > 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) +
I can confirm that the vlan limit test seems to be flaky, but stylistically, it should be "sizeof flow->cr.flow" here, without the parenthesis. Cheers, M > + 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 > d...@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev