[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]

 



Hello,

IIRC it is ok. The TCA_KIND is used as upper level ID. TCA_TBF_PARAMS
is in second level, it is contained as data of TBF kind. Take dump
of whole NL message and study carefully.
It is like:
TCA_KIND  "TBF"
TCA_XXXX {
  TCA_TBF_PARAMS ....
  TCA_TBF_XXXX .....
}
TCA_YYY ...

So that when rtnetlink_rev_msg parses message first time it skips
all occurences of TCA_TBF_*. q_tbf is given data part of TCA_XXXX
(can't remember name) and it calls rt parse function again on the
data.
devik

> =A1=A1=A1=A1 I want to send a command "tc qdisc add dev eth0 root tbf rat=
e 220kbit latency 50ms burst 1540" from TC,
> I found that a attribute with type of 1 is added to the nlmsg twice:
>=20
>     first time in the function of tc_qdisc_modify() in file of tc_qdisc.c=
:
> =09"if (k[0])
> =09=09addattr_l(&req.n, sizeof(req), TCA_KIND, k, strlen(k)+1);"
>=20
> =09second time in the function of tbf_parse_opt() in file of q_tbf.c:
>     "addattr_l(n, 2024, TCA_TBF_PARMS, &opt, sizeof(opt));"
>=20
> =09the value of TCA_KIND and TCA_TBF_PARAMS is both 1,so the nlmsg consis=
ts two attribute with type of 1.
>=20
>     when this nlmsg is dealed with in the kernel,I found a problem:
>=20
>     in the net/core/rtnetlink.c, function rtnetlink_rev_msg(),when:
>=20
> =09"if (nlh->nlmsg_len > min_len) {
> =09=09int attrlen =3D nlh->nlmsg_len - NLMSG_ALIGN(min_len);
> =09=09struct rtattr *attr =3D (void*)nlh + NLMSG_ALIGN(min_len);
>=20
> =09=09while (RTA_OK(attr, attrlen)) {
> =09=09=09unsigned flavor =3D attr->rta_type;
> =09=09=09if (flavor) {
> =09=09=09=09if (flavor > rta_max[sz_idx])
> =09=09=09=09=09goto err_inval;
> =09=09=09=09rta[flavor-1] =3D attr;
> =09=09=09}
> =09=09=09attr =3D RTA_NEXT(attr, attrlen);
> =09=09}
> =09}"
>=20
> =09at the begining of these lines, the first attribute(TCA_KIND) can be s=
tored in rta[1], but when handling
> the second attribute, it is stored in the same rta[1]! so the first attri=
bute disappeared!!
>     of course the treatment followed will make a mistake.
>     who can tell me why?
>=20
>=20
> =A1=A1=A1=A1=A1=A1best regards!
>=20
>  =09=09=09=09
> =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=
=A1=A1=A1=A1Mebius Huang
> =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=
=A1=A1=A1=A1hxgang@csnet4.cs.tsinghua.edu.cn
> =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A12000-02-21
> ,=04S
> f=A2=96)=E0=96+-=FC=B0=11L)=9A=8AY=9A=9D=DB=3Djya=B6=DA~=FF=F9=9A=8AY=9A=
=9D=DB=3Djy=7F=99=A8=A5=99=A9=FF=96+-=8Aw=E8=FEV=AB=B5=C1=CEY3=BE=86=DBi=FB=
=FF=E5j=BB\=A2=B8?



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