Use NLMSG_TAIL

(Logical change 1.127)
This commit is contained in:
4!tgraf 2005-01-18 01:24:18 +00:00
parent 60a383ae5f
commit 228569c3ff
8 changed files with 20 additions and 24 deletions

View File

@ -54,7 +54,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
if (argc == 0) if (argc == 0)
return 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); addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
while (argc > 0) { while (argc > 0) {
@ -125,7 +125,7 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
} }
argc--; argv++; argc--; argv++;
} }
tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail; tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
if (order) { if (order) {
fh &= ~0x7F00; fh &= ~0x7F00;
fh |= (order<<8)&0x7F00; fh |= (order<<8)&0x7F00;

View File

@ -189,7 +189,7 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc, char *
if (argc == 0) if (argc == 0)
return 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); addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
while (argc > 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) if (pinfo_ok)
addattr_l(n, 4096, TCA_RSVP_PINFO, &pinfo, sizeof(pinfo)); 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; return 0;
} }

View File

@ -177,7 +177,7 @@ parse_gact(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struc
if (!ok) if (!ok)
return -1; 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_id, NULL, 0);
addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof (p)); addattr_l(n, MAX_MSG, TCA_GACT_PARMS, &p, sizeof (p));
#ifdef CONFIG_GACT_PROB #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)); addattr_l(n, MAX_MSG, TCA_GACT_PROB, &pp, sizeof (pp));
} }
#endif #endif
tail->rta_len = tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
(((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail;
*argc_p = argc; *argc_p = argc;
*argv_p = argv; *argv_p = argv;

View File

@ -179,12 +179,12 @@ static int atm_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
perror("ioctl ATMARP_MKIP"); perror("ioctl ATMARP_MKIP");
return -1; 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_OPTIONS,NULL,0);
addattr_l(n,1024,TCA_ATM_FD,&s,sizeof(s)); addattr_l(n,1024,TCA_ATM_FD,&s,sizeof(s));
if (excess) addattr_l(n,1024,TCA_ATM_EXCESS,&excess,sizeof(excess)); 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); 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; return 0;
} }

View File

@ -71,7 +71,7 @@ static int dsmark_parse_opt(struct qdisc_util *qu, int argc, char **argv,
explain(); explain();
return -1; 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_OPTIONS,NULL,0);
addattr_l(n,1024,TCA_DSMARK_INDICES,&ind,sizeof(ind)); addattr_l(n,1024,TCA_DSMARK_INDICES,&ind,sizeof(ind));
if (dflt != -1) { 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)); 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); 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; return 0;
} }
@ -98,7 +98,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
__u8 tmp; __u8 tmp;
char *end; char *end;
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_OPTIONS,NULL,0);
while (argc > 0) { while (argc > 0) {
if (!strcmp(*argv,"mask")) { if (!strcmp(*argv,"mask")) {
@ -126,7 +126,7 @@ static int dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
argc--; argc--;
argv++; argv++;
} }
tail->rta_len = (((void *) n)+n->nlmsg_len)-(void *) tail; tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0; return 0;
} }

View File

@ -106,11 +106,10 @@ if ((!opt.DPs) || (!opt.def_DP))
} }
DPRINTF("TC_GRED: sending DPs=%d default=%d\n",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; 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_OPTIONS, NULL, 0);
addattr_l(n, 1024, TCA_GRED_DPS, &opt, sizeof(struct tc_gred_sopt)); 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; 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; 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_OPTIONS, NULL, 0);
addattr_l(n, 1024, TCA_GRED_PARMS, &opt, sizeof(opt)); addattr_l(n, 1024, TCA_GRED_PARMS, &opt, sizeof(opt));
addattr_l(n, 1024, TCA_GRED_STAB, sbuf, 256); 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; return 0;
} }

View File

@ -149,12 +149,11 @@ static int red_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
#endif #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_OPTIONS, NULL, 0);
addattr_l(n, 1024, TCA_RED_PARMS, &opt, sizeof(opt)); addattr_l(n, 1024, TCA_RED_PARMS, &opt, sizeof(opt));
addattr_l(n, 1024, TCA_RED_STAB, sbuf, 256); 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; return 0;
} }

View File

@ -187,13 +187,13 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
opt.peakrate.mpu = mpu; 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, 1024, TCA_OPTIONS, NULL, 0);
addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt)); addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt));
addattr_l(n, 3024, TCA_TBF_RTAB, rtab, 1024); addattr_l(n, 3024, TCA_TBF_RTAB, rtab, 1024);
if (opt.peakrate.rate) if (opt.peakrate.rate)
addattr_l(n, 4096, TCA_TBF_PTAB, ptab, 1024); 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; return 0;
} }