From 228569c3ff79468f4c7580fd88b0d6a34ebdc311 Mon Sep 17 00:00:00 2001 From: 4!tgraf <4!tgraf> Date: Tue, 18 Jan 2005 01:24:18 +0000 Subject: Use NLMSG_TAIL (Logical change 1.127) --- tc/f_route.c | 4 ++-- tc/f_rsvp.c | 4 ++-- tc/m_gact.c | 5 ++--- tc/q_atm.c | 4 ++-- tc/q_dsmark.c | 8 ++++---- tc/q_gred.c | 10 ++++------ tc/q_red.c | 5 ++--- tc/q_tbf.c | 4 ++-- 8 files changed, 20 insertions(+), 24 deletions(-) (limited to 'tc') diff --git a/tc/f_route.c b/tc/f_route.c index 15c638c8..f3f9bcc4 100644 --- a/tc/f_route.c +++ b/tc/f_route.c @@ -54,7 +54,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char if (argc == 0) 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 > 0) { @@ -125,7 +125,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char } argc--; argv++; } - tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; if (order) { fh &= ~0x7F00; fh |= (order<<8)&0x7F00; diff --git a/tc/f_rsvp.c b/tc/f_rsvp.c index 3f33696d..8faa22e7 100644 --- a/tc/f_rsvp.c +++ b/tc/f_rsvp.c @@ -189,7 +189,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char * if (argc == 0) 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 > 0) { @@ -282,7 +282,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char * if (pinfo_ok) addattr_l(n, 4096, TCA_RSVP_PINFO, &pinfo, sizeof(pinfo)); - tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } diff --git a/tc/m_gact.c b/tc/m_gact.c index f542c788..55cba10d 100644 --- a/tc/m_gact.c +++ b/tc/m_gact.c @@ -177,7 +177,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc if (!ok) return -1; - tail = (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)); + tail = NLMSG_TAIL(n); addattr_l(n, MAX_MSG, tca_id, NULL, 0); addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof (p)); #ifdef CONFIG_GACT_PROB @@ -185,8 +185,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc addattr_l(n, MAX_MSG, TCA_GACT_PROB, &pp, sizeof (pp)); } #endif - tail->rta_len = - (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; *argc_p = argc; *argv_p = argv; diff --git a/tc/q_atm.c b/tc/q_atm.c index bd991a94..ff9d22e6 100644 --- a/tc/q_atm.c +++ b/tc/q_atm.c @@ -179,12 +179,12 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, perror("ioctl ATMARP_MKIP"); return -1; } - tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len)); + tail = NLMSG_TAIL(n); addattr_l(n,1024,TCA_OPTIONS,NULL,0); addattr_l(n,1024,TCA_ATM_FD,&s,sizeof(s)); if (excess) addattr_l(n,1024,TCA_ATM_EXCESS,&excess,sizeof(excess)); if (hdr_len != -1) addattr_l(n,1024,TCA_ATM_HDR,hdr,hdr_len); - tail->rta_len = (((void *) n)+NLMSG_ALIGN(n->nlmsg_len))-(void *) tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } diff --git a/tc/q_dsmark.c b/tc/q_dsmark.c index f02ff1f9..cdb5bf2f 100644 --- a/tc/q_dsmark.c +++ b/tc/q_dsmark.c @@ -71,7 +71,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv, explain(); return -1; } - tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len)); + tail = NLMSG_TAIL(n); addattr_l(n,1024,TCA_OPTIONS,NULL,0); addattr_l(n,1024,TCA_DSMARK_INDICES,&ind,sizeof(ind)); if (dflt != -1) { @@ -80,7 +80,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv, addattr_l(n,1024,TCA_DSMARK_DEFAULT_INDEX,&tmp,sizeof(tmp)); } if (set_tc_index) addattr_l(n,1024,TCA_DSMARK_SET_TC_INDEX,NULL,0); - tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } @@ -98,7 +98,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, __u8 tmp; char *end; - tail = (struct rtattr *) (((void *) n)+NLMSG_ALIGN(n->nlmsg_len)); + tail = NLMSG_TAIL(n); addattr_l(n,1024,TCA_OPTIONS,NULL,0); while (argc > 0) { if (!strcmp(*argv,"mask")) { @@ -126,7 +126,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, argc--; argv++; } - tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } diff --git a/tc/q_gred.c b/tc/q_gred.c index 8761328c..be9e73a5 100644 --- a/tc/q_gred.c +++ b/tc/q_gred.c @@ -106,11 +106,10 @@ if ((!opt.DPs) || (!opt.def_DP)) } DPRINTF("TC_GRED: sending DPs=%d default=%d\n",opt.DPs,opt.def_DP); n->nlmsg_flags|=NLM_F_CREATE; - tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len)); - + tail = NLMSG_TAIL(n); addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); addattr_l(n, 1024, TCA_GRED_DPS, &opt, sizeof(struct tc_gred_sopt)); - tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } /* @@ -252,12 +251,11 @@ static int gred_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct n } opt.Scell_log = wlog; - tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len)); - + tail = NLMSG_TAIL(n); addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); addattr_l(n, 1024, TCA_GRED_PARMS, &opt, sizeof(opt)); addattr_l(n, 1024, TCA_GRED_STAB, sbuf, 256); - tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } diff --git a/tc/q_red.c b/tc/q_red.c index d2ef221b..3e0b1ec3 100644 --- a/tc/q_red.c +++ b/tc/q_red.c @@ -149,12 +149,11 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl #endif } - tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len)); - + tail = NLMSG_TAIL(n); addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); addattr_l(n, 1024, TCA_RED_PARMS, &opt, sizeof(opt)); addattr_l(n, 1024, TCA_RED_STAB, sbuf, 256); - tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } diff --git a/tc/q_tbf.c b/tc/q_tbf.c index 8f8c2776..d251435e 100644 --- a/tc/q_tbf.c +++ b/tc/q_tbf.c @@ -187,13 +187,13 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl opt.peakrate.mpu = mpu; } - tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len)); + tail = NLMSG_TAIL(n); addattr_l(n, 1024, TCA_OPTIONS, NULL, 0); addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt)); addattr_l(n, 3024, TCA_TBF_RTAB, rtab, 1024); if (opt.peakrate.rate) addattr_l(n, 4096, TCA_TBF_PTAB, ptab, 1024); - tail->rta_len = (((void*)n)+NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail; + tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } -- cgit v1.2.3