Message ID | 1426611124-2295-3-git-send-email-vadim4j@gmail.com |
---|---|
State | Rejected, archived |
Delegated to: | stephen hemminger |
Headers | show |
On 03/17/2015 05:52 PM, Vadim Kochan wrote: ... > Changed default class name file cls_names -> tc_cls. Why that? > Signed-off-by: Vadim Kochan <vadim4j@gmail.com> > --- > tc/tc_util.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/tc/tc_util.c b/tc/tc_util.c > index feae439..5213e9e 100644 > --- a/tc/tc_util.c > +++ b/tc/tc_util.c ... > static struct db_names *cls_names = NULL; > > -#define NAMES_DB "/etc/iproute2/cls_names" > +#define NAMES_DB "/etc/iproute2/tc_cls" > > int cls_names_init(char *path) > { > - cls_names = db_names_alloc(path ?: NAMES_DB); > - if (!cls_names) { > - fprintf(stderr, "Error while opening class names file\n"); > + int ret = -1; > + > + cls_names = db_names_alloc(); > + if (!cls_names) > + return -1; > + > + ret = db_names_load(cls_names, path ?: NAMES_DB); > + if (ret == -ENOENT && path) { > + fprintf(stderr, "Can't open class names file: %s\n", path); That would mean that existing users having a /etc/iproute2/cls_names file would suddenly not see class names anymore? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Mar 17, 2015 at 06:34:06PM +0100, Daniel Borkmann wrote: > On 03/17/2015 05:52 PM, Vadim Kochan wrote: > ... > >Changed default class name file cls_names -> tc_cls. > > Why that? > tc_cls seems better and shorter. > >Signed-off-by: Vadim Kochan <vadim4j@gmail.com> > >--- > > tc/tc_util.c | 19 +++++++++++++++---- > > 1 file changed, 15 insertions(+), 4 deletions(-) > > > >diff --git a/tc/tc_util.c b/tc/tc_util.c > >index feae439..5213e9e 100644 > >--- a/tc/tc_util.c > >+++ b/tc/tc_util.c > ... > > static struct db_names *cls_names = NULL; > > > >-#define NAMES_DB "/etc/iproute2/cls_names" > >+#define NAMES_DB "/etc/iproute2/tc_cls" > > > > int cls_names_init(char *path) > > { > >- cls_names = db_names_alloc(path ?: NAMES_DB); > >- if (!cls_names) { > >- fprintf(stderr, "Error while opening class names file\n"); > >+ int ret = -1; > >+ > >+ cls_names = db_names_alloc(); > >+ if (!cls_names) > >+ return -1; > >+ > >+ ret = db_names_load(cls_names, path ?: NAMES_DB); > >+ if (ret == -ENOENT && path) { > >+ fprintf(stderr, "Can't open class names file: %s\n", path); > > That would mean that existing users having a /etc/iproute2/cls_names > file would suddenly not see class names anymore? Hm, but that was added few days ago. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 03/17/2015 07:21 PM, Vadim Kochan wrote: > On Tue, Mar 17, 2015 at 06:34:06PM +0100, Daniel Borkmann wrote: >> On 03/17/2015 05:52 PM, Vadim Kochan wrote: >> ... >>> Changed default class name file cls_names -> tc_cls. >> >> Why that? > > tc_cls seems better and shorter. > >>> Signed-off-by: Vadim Kochan <vadim4j@gmail.com> >>> --- >>> tc/tc_util.c | 19 +++++++++++++++---- >>> 1 file changed, 15 insertions(+), 4 deletions(-) >>> >>> diff --git a/tc/tc_util.c b/tc/tc_util.c >>> index feae439..5213e9e 100644 >>> --- a/tc/tc_util.c >>> +++ b/tc/tc_util.c >> ... >>> static struct db_names *cls_names = NULL; >>> >>> -#define NAMES_DB "/etc/iproute2/cls_names" >>> +#define NAMES_DB "/etc/iproute2/tc_cls" >>> >>> int cls_names_init(char *path) >>> { >>> - cls_names = db_names_alloc(path ?: NAMES_DB); >>> - if (!cls_names) { >>> - fprintf(stderr, "Error while opening class names file\n"); >>> + int ret = -1; >>> + >>> + cls_names = db_names_alloc(); >>> + if (!cls_names) >>> + return -1; >>> + >>> + ret = db_names_load(cls_names, path ?: NAMES_DB); >>> + if (ret == -ENOENT && path) { >>> + fprintf(stderr, "Can't open class names file: %s\n", path); >> >> That would mean that existing users having a /etc/iproute2/cls_names >> file would suddenly not see class names anymore? > > Hm, but that was added few days ago. Ok, my bad, sorry for the noise. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello. On 03/17/2015 07:52 PM, Vadim Kochan wrote: > From: Vadim Kochan <vadim4j@gmail.com> > If '-nm' specified then do not fail if there is no > default class names file in /etc/iproute2. > Changed default class name file cls_names -> tc_cls. > Signed-off-by: Vadim Kochan <vadim4j@gmail.com> > --- > tc/tc_util.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > diff --git a/tc/tc_util.c b/tc/tc_util.c > index feae439..5213e9e 100644 > --- a/tc/tc_util.c > +++ b/tc/tc_util.c [...] > @@ -33,15 +34,25 @@ > > static struct db_names *cls_names = NULL; > > -#define NAMES_DB "/etc/iproute2/cls_names" > +#define NAMES_DB "/etc/iproute2/tc_cls" > > int cls_names_init(char *path) > { > - cls_names = db_names_alloc(path ?: NAMES_DB); > - if (!cls_names) { > - fprintf(stderr, "Error while opening class names file\n"); > + int ret = -1; Pointless initializer. > + > + cls_names = db_names_alloc(); > + if (!cls_names) > + return -1; > + > + ret = db_names_load(cls_names, path ?: NAMES_DB); > + if (ret == -ENOENT && path) { > + fprintf(stderr, "Can't open class names file: %s\n", path); > return -1; > } > + if (ret) { > + db_names_free(cls_names); > + cls_names = NULL; > + } > > return 0; > } WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/tc/tc_util.c b/tc/tc_util.c index feae439..5213e9e 100644 --- a/tc/tc_util.c +++ b/tc/tc_util.c @@ -21,6 +21,7 @@ #include <arpa/inet.h> #include <string.h> #include <math.h> +#include <errno.h> #include "utils.h" #include "names.h" @@ -33,15 +34,25 @@ static struct db_names *cls_names = NULL; -#define NAMES_DB "/etc/iproute2/cls_names" +#define NAMES_DB "/etc/iproute2/tc_cls" int cls_names_init(char *path) { - cls_names = db_names_alloc(path ?: NAMES_DB); - if (!cls_names) { - fprintf(stderr, "Error while opening class names file\n"); + int ret = -1; + + cls_names = db_names_alloc(); + if (!cls_names) + return -1; + + ret = db_names_load(cls_names, path ?: NAMES_DB); + if (ret == -ENOENT && path) { + fprintf(stderr, "Can't open class names file: %s\n", path); return -1; } + if (ret) { + db_names_free(cls_names); + cls_names = NULL; + } return 0; }