From 23200a673f79a31d278bd369f742ae12ad1d308a Mon Sep 17 00:00:00 2001 From: cheoleun moon Date: Tue, 13 Dec 2022 16:09:43 +0900 Subject: [PATCH] Add /usr/lib64 to testpath https://github.com/thom311/libnl/commit/69b730e23e79adb8f38fff018c2b108b9ca9cfb7 Change-Id: Ifdf3c291bc71841015a82afb4e6b0ea05a57634b Signed-off-by: cheoleun moon --- lib/route/sch/netem.c | 88 +++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/route/sch/netem.c b/lib/route/sch/netem.c index 18878a7..54ee0ab 100644 --- a/lib/route/sch/netem.c +++ b/lib/route/sch/netem.c @@ -123,18 +123,18 @@ static int netem_msg_parser(struct rtnl_qdisc *qdisc) netem->qnm_mask |= (SCH_NETEM_ATTR_RO_PROB | SCH_NETEM_ATTR_RO_CORR); } - + if (tb[TCA_NETEM_CORRUPT]) { struct tc_netem_corrupt corrupt; - + nla_memcpy(&corrupt, tb[TCA_NETEM_CORRUPT], sizeof(corrupt)); netem->qnm_crpt.nmcr_probability = corrupt.probability; netem->qnm_crpt.nmcr_correlation = corrupt.correlation; - + netem->qnm_mask |= (SCH_NETEM_ATTR_CORRUPT_PROB | SCH_NETEM_ATTR_CORRUPT_CORR); } - + /* sch_netem does not currently dump TCA_NETEM_DELAY_DIST */ netem->qnm_dist.dist_data = NULL; netem->qnm_dist.dist_size = 0; @@ -146,17 +146,17 @@ static int netem_msg_parser(struct rtnl_qdisc *qdisc) static void netem_free_data(struct rtnl_qdisc *qdisc) { struct rtnl_netem *netem; - + if ( ! qdisc ) return; - + netem = netem_qdisc(qdisc); if ( ! netem ) return; - + if ( netem->qnm_dist.dist_data ) free(netem->qnm_dist.dist_data); - + netem = NULL; - + free (qdisc->q_subdata); } @@ -176,7 +176,7 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) struct tc_netem_reorder reorder; struct tc_netem_corrupt corrupt; struct rtnl_netem *netem; - + unsigned char set_correlation = 0, set_reorder = 0, set_corrupt = 0, set_dist = 0; @@ -188,16 +188,16 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) netem = netem_qdisc(qdisc); if (!netem || !msg) return EFAULT; - + msg->nm_nlh->nlmsg_flags |= NLM_F_REQUEST; - + if ( netem->qnm_ro.nmro_probability != 0 ) { if (netem->qnm_latency == 0) { return -NLE_MISSING_ATTR; } if (netem->qnm_gap == 0) netem->qnm_gap = 1; } - else if ( netem->qnm_gap ) { + else if ( netem->qnm_gap ) { return -NLE_MISSING_ATTR; } @@ -207,7 +207,7 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) } set_correlation = 1; } - + if ( netem->qnm_corr.nmc_loss != 0 ) { if ( netem->qnm_loss == 0 ) { return -NLE_MISSING_ATTR; @@ -221,17 +221,17 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) } set_correlation = 1; } - + if ( netem->qnm_ro.nmro_probability != 0 ) set_reorder = 1; else if ( netem->qnm_ro.nmro_correlation != 0 ) { return -NLE_MISSING_ATTR; } - + if ( netem->qnm_crpt.nmcr_probability != 0 ) set_corrupt = 1; else if ( netem->qnm_crpt.nmcr_correlation != 0 ) { return -NLE_MISSING_ATTR; } - + if ( netem->qnm_dist.dist_data && netem->qnm_dist.dist_size ) { if (netem->qnm_latency == 0 || netem->qnm_jitter == 0) { return -NLE_MISSING_ATTR; @@ -240,7 +240,7 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) /* Resize to accomodate the large distribution table */ int new_msg_len = msg->nm_size + netem->qnm_dist.dist_size * sizeof(netem->qnm_dist.dist_data[0]); - + msg->nm_nlh = (struct nlmsghdr *) realloc(msg->nm_nlh, new_msg_len); if ( msg->nm_nlh == NULL ) return -NLE_NOMEM; @@ -248,16 +248,16 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) set_dist = 1; } } - + opts.latency = netem->qnm_latency; opts.limit = netem->qnm_limit ? netem->qnm_limit : 1000; opts.loss = netem->qnm_loss; opts.gap = netem->qnm_gap; opts.duplicate = netem->qnm_duplicate; opts.jitter = netem->qnm_jitter; - + NLA_PUT(msg, TCA_OPTIONS, sizeof(opts), &opts); - + if ( set_correlation ) { cor.delay_corr = netem->qnm_corr.nmc_delay; cor.loss_corr = netem->qnm_corr.nmc_loss; @@ -265,21 +265,21 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) NLA_PUT(msg, TCA_NETEM_CORR, sizeof(cor), &cor); } - + if ( set_reorder ) { reorder.probability = netem->qnm_ro.nmro_probability; reorder.correlation = netem->qnm_ro.nmro_correlation; NLA_PUT(msg, TCA_NETEM_REORDER, sizeof(reorder), &reorder); } - + if ( set_corrupt ) { corrupt.probability = netem->qnm_crpt.nmcr_probability; corrupt.correlation = netem->qnm_crpt.nmcr_correlation; NLA_PUT(msg, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt); } - + if ( set_dist ) { NLA_PUT(msg, TCA_NETEM_DELAY_DIST, netem->qnm_dist.dist_size * sizeof(netem->qnm_dist.dist_data[0]), @@ -292,14 +292,14 @@ int netem_build_msg(struct rtnl_qdisc *qdisc, struct nl_msg *msg) */ struct nlattr* head = (struct nlattr *)(NLMSG_DATA(msg->nm_nlh) + NLMSG_LENGTH(sizeof(struct tcmsg)) - NLMSG_ALIGNTO); - + struct nlattr* tail = (struct nlattr *)(((void *) (msg->nm_nlh)) + NLMSG_ALIGN(msg->nm_nlh->nlmsg_len)); - + int old_len = head->nla_len; head->nla_len = (void *)tail - (void *)head; msg->nm_nlh->nlmsg_len += (head->nla_len - old_len); - + return err; nla_put_failure: return -NLE_MSGSIZE; @@ -323,7 +323,7 @@ int rtnl_netem_set_limit(struct rtnl_qdisc *qdisc, int limit) netem = netem_alloc(qdisc); if (!netem) return -NLE_NOMEM; - + netem->qnm_limit = limit; netem->qnm_mask |= SCH_NETEM_ATTR_LIMIT; @@ -467,7 +467,7 @@ int rtnl_netem_get_reorder_correlation(struct rtnl_qdisc *qdisc) * @name Corruption * @{ */ - + /** * Set corruption probability of netem qdisc. * @arg qdisc Netem qdisc to be modified. @@ -859,37 +859,37 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist netem = netem_alloc(qdisc); if (!netem) return -NLE_NOMEM; - + FILE *f = NULL; int i, n = 0; size_t len = 2048; char *line; char name[NAME_MAX]; char dist_suffix[] = ".dist"; - + /* If the given filename already ends in .dist, don't append it later */ char *test_suffix = strstr(dist_type, dist_suffix); if (test_suffix != NULL && strlen(test_suffix) == 5) strcpy(dist_suffix, ""); - + /* Check several locations for the dist file */ - char *test_path[] = { "", "./", "/usr/lib/tc/", "/usr/local/lib/tc/" }; - + char *test_path[] = { "", "./", "/usr/lib/tc/", "/usr/lib64/tc/", "/usr/local/lib/tc/" }; + for (i = 0; i < sizeof(test_path) && f == NULL; i++) { snprintf(name, NAME_MAX, "%s%s%s", test_path[i], dist_type, dist_suffix); f = fopen(name, "r"); } - + if ( f == NULL ) return -nl_syserr2nlerr(errno); - + netem->qnm_dist.dist_data = (int16_t *) calloc (MAXDIST, sizeof(int16_t)); - + line = (char *) calloc (sizeof(char), len + 1); - + while (getline(&line, &len, f) != -1) { char *p, *endp; - + if (*line == '\n' || *line == '#') continue; @@ -903,16 +903,16 @@ int rtnl_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, const char *dist return -NLE_INVAL; } netem->qnm_dist.dist_data[n++] = x; - } + } } - + free(line); - + netem->qnm_dist.dist_size = n; netem->qnm_mask |= SCH_NETEM_ATTR_DIST; - + fclose(f); - return 0; + return 0; } /** @} */ -- 2.7.4