Message ID | 20221215175230.1907938-2-idosch@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 935d942e69392bc66c837db1ce453feed8308392 |
Delegated to: | David Ahern |
Headers | show |
Series | bridge: mdb: Add support for new attributes | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 15/12/2022 19:52, Ido Schimmel wrote: > Currently, the only attribute inside the 'MDBA_SET_ENTRY_ATTRS' nest is > 'MDBE_ATTR_SOURCE', but subsequent patches are going to add more > attributes to the nest. > > Prepare for the addition of these attributes by determining the > necessity of the nest from a boolean variable that is set whenever one > of these attributes is parsed. This avoids the need to have one long > condition that checks for the presence of one of the individual > attributes. > > Signed-off-by: Ido Schimmel <idosch@nvidia.com> > --- > bridge/mdb.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/bridge/mdb.c b/bridge/mdb.c > index d3afc900e798..4ae91f15dac8 100644 > --- a/bridge/mdb.c > +++ b/bridge/mdb.c > @@ -488,6 +488,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) > }; > char *d = NULL, *p = NULL, *grp = NULL, *src = NULL; > struct br_mdb_entry entry = {}; > + bool set_attrs = false; > short vid = 0; > > while (argc > 0) { > @@ -511,6 +512,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) > } else if (strcmp(*argv, "src") == 0) { > NEXT_ARG(); > src = *argv; > + set_attrs = true; > } else { > if (matches(*argv, "help") == 0) > usage(); > @@ -538,7 +540,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) > > entry.vid = vid; > addattr_l(&req.n, sizeof(req), MDBA_SET_ENTRY, &entry, sizeof(entry)); > - if (src) { > + if (set_attrs) { > struct rtattr *nest = addattr_nest(&req.n, sizeof(req), > MDBA_SET_ENTRY_ATTRS); > struct in6_addr src_ip6; Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
diff --git a/bridge/mdb.c b/bridge/mdb.c index d3afc900e798..4ae91f15dac8 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -488,6 +488,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) }; char *d = NULL, *p = NULL, *grp = NULL, *src = NULL; struct br_mdb_entry entry = {}; + bool set_attrs = false; short vid = 0; while (argc > 0) { @@ -511,6 +512,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) } else if (strcmp(*argv, "src") == 0) { NEXT_ARG(); src = *argv; + set_attrs = true; } else { if (matches(*argv, "help") == 0) usage(); @@ -538,7 +540,7 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv) entry.vid = vid; addattr_l(&req.n, sizeof(req), MDBA_SET_ENTRY, &entry, sizeof(entry)); - if (src) { + if (set_attrs) { struct rtattr *nest = addattr_nest(&req.n, sizeof(req), MDBA_SET_ENTRY_ATTRS); struct in6_addr src_ip6;
Currently, the only attribute inside the 'MDBA_SET_ENTRY_ATTRS' nest is 'MDBE_ATTR_SOURCE', but subsequent patches are going to add more attributes to the nest. Prepare for the addition of these attributes by determining the necessity of the nest from a boolean variable that is set whenever one of these attributes is parsed. This avoids the need to have one long condition that checks for the presence of one of the individual attributes. Signed-off-by: Ido Schimmel <idosch@nvidia.com> --- bridge/mdb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)