From 3b3ecd31c1e513f029ebbb83f2e808553de0a741 Mon Sep 17 00:00:00 2001 From: 4!tgraf <4!tgraf> Date: Tue, 18 Jan 2005 22:11:58 +0000 Subject: [PATCH] Use parse_rtattr_nested (Logical change 1.129) --- tc/f_route.c | 4 +--- tc/f_rsvp.c | 4 +--- tc/f_tcindex.c | 10 +++++----- tc/m_gact.c | 3 +-- tc/q_atm.c | 7 ++++--- tc/q_gred.c | 3 +-- tc/q_red.c | 3 +-- tc/q_tbf.c | 3 +-- 8 files changed, 15 insertions(+), 22 deletions(-) diff --git a/tc/f_route.c b/tc/f_route.c index f3f9bcc4..e9de218b 100644 --- a/tc/f_route.c +++ b/tc/f_route.c @@ -143,9 +143,7 @@ static int route_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, if (opt == NULL) return 0; - memset(tb, 0, sizeof(tb)); - if (opt) - parse_rtattr(tb, TCA_ROUTE4_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)); + parse_rtattr_nested(tb, TCA_ROUTE4_MAX, opt); if (handle) fprintf(f, "fh 0x%08x ", handle); diff --git a/tc/f_rsvp.c b/tc/f_rsvp.c index 8faa22e7..13fcf979 100644 --- a/tc/f_rsvp.c +++ b/tc/f_rsvp.c @@ -322,9 +322,7 @@ static int rsvp_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, _ if (opt == NULL) return 0; - memset(tb, 0, sizeof(tb)); - if (opt) - parse_rtattr(tb, TCA_RSVP_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)); + parse_rtattr_nested(tb, TCA_RSVP_MAX, opt); if (handle) fprintf(f, "fh 0x%08x ", handle); diff --git a/tc/f_tcindex.c b/tc/f_tcindex.c index 45f0db22..39ac75ad 100644 --- a/tc/f_tcindex.c +++ b/tc/f_tcindex.c @@ -43,7 +43,7 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc, } } if (!argc) return 0; - tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len)); + tail = NLMSG_TAIL(n); addattr_l(n,4096,TCA_OPTIONS,NULL,0); while (argc) { if (!strcmp(*argv,"hash")) { @@ -117,7 +117,7 @@ static int tcindex_parse_opt(struct filter_util *qu, char *handle, int argc, argc--; argv++; } - tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } @@ -127,10 +127,10 @@ static int tcindex_print_opt(struct filter_util *qu, FILE *f, { struct rtattr *tb[TCA_TCINDEX_MAX+1]; - if (!opt) return 0; + if (opt == NULL) + return 0; - memset(tb, 0, sizeof(tb)); - parse_rtattr(tb, TCA_TCINDEX_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)); + parse_rtattr_nested(tb, TCA_TCINDEX_MAX, opt); if (handle != ~0) fprintf(f,"handle 0x%04x ",handle); if (tb[TCA_TCINDEX_HASH]) { diff --git a/tc/m_gact.c b/tc/m_gact.c index 55cba10d..4bb50410 100644 --- a/tc/m_gact.c +++ b/tc/m_gact.c @@ -207,8 +207,7 @@ print_gact(struct action_util *au,FILE * f, struct rtattr *arg) if (arg == NULL) return -1; - memset(tb, 0, sizeof (tb)); - parse_rtattr(tb, TCA_GACT_MAX, RTA_DATA(arg), RTA_PAYLOAD(arg)); + parse_rtattr_nested(tb, TCA_GACT_MAX, arg); if (tb[TCA_GACT_PARMS] == NULL) { fprintf(f, "[NULL gact parameters]"); diff --git a/tc/q_atm.c b/tc/q_atm.c index ff9d22e6..4c8dc0b8 100644 --- a/tc/q_atm.c +++ b/tc/q_atm.c @@ -195,9 +195,10 @@ static int atm_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) struct rtattr *tb[TCA_ATM_MAX+1]; char buffer[MAX_ATM_ADDR_LEN+1]; - if (!opt) return 0; - memset(tb, 0, sizeof(tb)); - parse_rtattr(tb, TCA_ATM_MAX, RTA_DATA(opt), RTA_PAYLOAD(opt)); + if (opt == NULL) + return 0; + + parse_rtattr_nested(tb, TCA_ATM_MAX, opt); if (tb[TCA_ATM_ADDR]) { if (RTA_PAYLOAD(tb[TCA_ATM_ADDR]) < sizeof(struct sockaddr_atmpvc)) diff --git a/tc/q_gred.c b/tc/q_gred.c index be9e73a5..6cb6e396 100644 --- a/tc/q_gred.c +++ b/tc/q_gred.c @@ -273,8 +273,7 @@ static int gred_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (opt == NULL) return 0; - memset(tb, 0, sizeof(tb)); - parse_rtattr(tb, TCA_GRED_STAB, RTA_DATA(opt), RTA_PAYLOAD(opt)); + parse_rtattr_nested(tb, TCA_GRED_STAB, opt); if (tb[TCA_GRED_PARMS] == NULL) return -1; diff --git a/tc/q_red.c b/tc/q_red.c index 3e0b1ec3..1743f6cf 100644 --- a/tc/q_red.c +++ b/tc/q_red.c @@ -168,8 +168,7 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (opt == NULL) return 0; - memset(tb, 0, sizeof(tb)); - parse_rtattr(tb, TCA_RED_STAB, RTA_DATA(opt), RTA_PAYLOAD(opt)); + parse_rtattr_nested(tb, TCA_RED_STAB, opt); if (tb[TCA_RED_PARMS] == NULL) return -1; diff --git a/tc/q_tbf.c b/tc/q_tbf.c index d251435e..6ed5e0bd 100644 --- a/tc/q_tbf.c +++ b/tc/q_tbf.c @@ -209,8 +209,7 @@ static int tbf_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) if (opt == NULL) return 0; - memset(tb, 0, sizeof(tb)); - parse_rtattr(tb, TCA_TBF_PTAB, RTA_DATA(opt), RTA_PAYLOAD(opt)); + parse_rtattr_nested(tb, TCA_TBF_PTAB, opt); if (tb[TCA_TBF_PARMS] == NULL) return -1;