]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Use NLMSG_TAIL
author8!tgraf <8!tgraf>
Tue, 18 Jan 2005 01:24:18 +0000 (01:24 +0000)
committer8!tgraf <8!tgraf>
Tue, 18 Jan 2005 01:24:18 +0000 (01:24 +0000)
(Logical change 1.127)

tc/f_u32.c
tc/m_action.c
tc/q_hfsc.c

index 1d96d63fb73d6ae0bcbefa950f49ead8730f2715..118225dc05bce503232fb9255d5f4a99746a2484 100644 (file)
@@ -794,7 +794,7 @@ static int u32_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, MAX_MSG, TCA_OPTIONS, NULL, 0);
 
        while (argc > 0) {
@@ -943,7 +943,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, int argc, char **
                addattr_l(n, MAX_MSG, TCA_U32_HASH, &htid, 4);
        if (sel_ok)
                addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel, sizeof(sel.sel)+sel.sel.nkeys*sizeof(struct tc_u32_key));
-       tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+       tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
        return 0;
 }
 
index 77bf4e0746034ad8abf60b0b25548aee9b0c0292..c640bebeab62d16cc0411fb8eb40f31a81842107 100644 (file)
@@ -144,8 +144,7 @@ parse_action(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n)
        if (argc <= 0)
                return -1;
 
-       tail = tail2 =
-           (struct rtattr *) (((void *) n) + NLMSG_ALIGN(n->nlmsg_len));
+       tail = tail2 = NLMSG_TAIL(n);
 
        addattr_l(n, MAX_MSG, tca_id, NULL, 0);
 
@@ -185,9 +184,7 @@ done0:
                                goto bad_val;
                        }
 
-                       tail =
-                           (struct rtattr *) (((void *) n) +
-                                      NLMSG_ALIGN(n->nlmsg_len));
+                       tail = NLMSG_TAIL(n);
                        addattr_l(n, MAX_MSG, ++prio, NULL, 0);
                        addattr_l(n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
 
@@ -197,9 +194,7 @@ done0:
                                fprintf(stderr,"bad action parsing\n");
                                goto bad_val;
                        }
-                       tail->rta_len =
-                           (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) -
-                           (void *) tail;
+                       tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
                        ok++;
                }
 
@@ -210,8 +205,7 @@ done0:
                goto bad_val;
        }
 
-       tail2->rta_len =
-           (((void *) n) + NLMSG_ALIGN(n->nlmsg_len)) - (void *) tail2;
+       tail2->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail2;
 
 done:
        *argc_p = argc;
@@ -376,8 +370,7 @@ int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p)
        argv +=1;
 
 
-       tail = (struct rtattr*)(((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len));
-
+       tail = NLMSG_TAIL(&req.n);
        addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
 
        while (argc > 0) {
@@ -425,17 +418,15 @@ int tc_action_gd(int cmd, unsigned flags, int *argc_p, char ***argv_p)
                        goto bad_val;
                }
 
-       tail2 =
-          (struct rtattr *) (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len));
-       addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
-       addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
-       addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i);
-       tail2->rta_len =
-           (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len)) - (void *) tail2;
+               tail2 = NLMSG_TAIL(&req.n);
+               addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
+               addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
+               addattr32(&req.n, MAX_MSG, TCA_ACT_INDEX, i);
+               tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
 
        }
 
-       tail->rta_len = (((void*)&req.n)+ NLMSG_ALIGN(req.n.nlmsg_len)) - (void*)tail;
+       tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
 
        if (rtnl_open(&rth, 0) < 0) {
                fprintf(stderr, "Cannot open rtnetlink\n");
@@ -485,14 +476,14 @@ int tc_action_modify(int cmd, unsigned flags, int *argc_p, char ***argv_p)
        req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
        req.n.nlmsg_flags = NLM_F_REQUEST|flags;
        req.n.nlmsg_type = cmd;
-       tail = (struct rtattr*)(((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len));
+       tail = NLMSG_TAIL(&req.n);
        argc -=1;
        argv +=1;
        if (parse_action(&argc, &argv, TCA_ACT_TAB, &req.n)) {
                fprintf(stderr, "Illegal \"action\"\n");
                return -1;
        }
-       tail->rta_len = (((void*)&req.n)+req.n.nlmsg_len) - (void*)tail;
+       tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
 
        if (rtnl_open(&rth, 0) < 0) {
                fprintf(stderr, "Cannot open rtnetlink\n");
@@ -530,11 +521,9 @@ int tc_act_list_or_flush(int argc, char **argv, int event)
 
        req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg));
 
-       tail = (struct rtattr*)(((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len));
-
+       tail = NLMSG_TAIL(&req.n);
        addattr_l(&req.n, MAX_MSG, TCA_ACT_TAB, NULL, 0);
-       tail2 =
-          (struct rtattr *) (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len));
+       tail2 = NLMSG_TAIL(&req.n);
 
        strncpy(k, *argv, sizeof (k) - 1);
 #ifdef CONFIG_GACT
@@ -555,10 +544,8 @@ int tc_act_list_or_flush(int argc, char **argv, int event)
 
        addattr_l(&req.n, MAX_MSG, ++prio, NULL, 0);
        addattr_l(&req.n, MAX_MSG, TCA_ACT_KIND, k, strlen(k) + 1);
-       tail2->rta_len =
-           (((void *) &req.n) + NLMSG_ALIGN(req.n.nlmsg_len)) - (void *) tail2;
-       tail->rta_len = (((void*)&req.n)+NLMSG_ALIGN(req.n.nlmsg_len)) - (void*)tail;
-
+       tail2->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail2;
+       tail->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail;
 
        if (rtnl_open(&rth, 0) < 0) {
                fprintf(stderr, "Cannot open rtnetlink\n");
index 021fbb5bad4c0c9d12307a6f4de73976b4cb9112..577ffe75a0359b1751e6721e460328eb6c95ebb3 100644 (file)
@@ -205,7 +205,7 @@ hfsc_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
                return -1;
        }
 
-       tail = (struct rtattr*)(((void*)n) + NLMSG_ALIGN(n->nlmsg_len));
+       tail = NLMSG_TAIL(n);
 
        addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
        if (rsc_ok)
@@ -215,7 +215,7 @@ hfsc_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
        if (usc_ok)
                addattr_l(n, 1024, TCA_HFSC_USC, &usc, sizeof(usc));
 
-       tail->rta_len = (((void*)n) + NLMSG_ALIGN(n->nlmsg_len)) - (void*)tail;
+       tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
        return 0;
 }