[LARTC] a question about q_tbf.c of TC

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



LARTC,hello!

   I want to send a command "tc qdisc add dev eth0 root tbf rate 220kbit latency 50ms burst 1540" from TC,
I found that a attribute with type of 1 is added to the nlmsg twice:

    first time in the function of tc_qdisc_modify() in file of tc_qdisc.c:
	"if (k[0])
		addattr_l(&req.n, sizeof(req), TCA_KIND, k, strlen(k)+1);"

	second time in the function of tbf_parse_opt() in file of q_tbf.c:
    "addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt));"

	the value of TCA_KIND and TCA_TBF_PARAMS is both 1,so the nlmsg consists two attribute with type of 1.

    when this nlmsg is dealed with in the kernel,I found a problem:

    in the net/core/rtnetlink.c, function rtnetlink_rev_msg(),when:

	"if (nlh->nlmsg_len > min_len) {
		int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
		struct rtattr *attr = (void*)nlh + NLMSG_ALIGN(min_len);

		while (RTA_OK(attr, attrlen)) {
			unsigned flavor = attr->rta_type;
			if (flavor) {
				if (flavor > rta_max[sz_idx])
					goto err_inval;
				rta[flavor-1] = attr;
			}
			attr = RTA_NEXT(attr, attrlen);
		}
	}"

	at the begining of these lines, the first attribute(TCA_KIND) can be stored in rta[1], but when handling
the second attribute, it is stored in the same rta[1]! so the first attribute disappeared!!
    of course the treatment followed will make a mistake.
    who can tell me why?


   best regards!

 				
              Mebius Huang
              hxgang@xxxxxxxxxxxxxxxxxxxxxxxxx
                 2000-02-21

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux