TC: Prostitution

Source: Internet
Author: User
Tags 0xc0

TC Learning originally is to think directly from the user state learning, but never thought Wow, Qdisc class two concepts directly to let me dizzy, directly look at the code bar

Call: TC Qdisc add dev tap0 root handle 1:HTB default 2

%STC 0xffffffff81744fe0:qdisc_create+0x0/0x410 [kernel] 0xffffffff81745597:tc_modify_qdisc+0x1a7/0x5b0 [kernel] 0xffffffff8172b336:rtnetlink_rcv_msg+0xe6/0x230 [kernel] 0xffffffff8174ee24:netlink_rcv_skb+0xa4/0xc0 [kernel] 0xffffffff8172b248:rtnetlink_rcv+0x28/0x30 [kernel] 0xffffffff8174e5da:netlink_unicast+0x12a/0x1b0 [kernel] 0xffffffff8174eb01:netlink_sendmsg+0x4a1/0x5f0 [kernel] 0xffffffff816fe098:sock_sendmsg+0x38/0x50 [kernel] 0XFFFFFFFF816FEB41: ___sys_sendmsg+0x281/0x290 [kernel] 0xffffffff816ff491: __sys_sendmsg+0x51/0x90 [kernel] 0xffffffff816ff4e2:sys_sendmsg+0x12/0x20 [kernel] 0xffffffff818244f2:entry_syscall_64_fastpath+0x16/0x71 [kernel]

When adding TC class, the call stack is:

TC 0xffffffff81741950:qdisc_create_dflt+0x0/0x80 [kernel] 0xffffffffc0a87abf [SCH_HTB] 0xffffffff81744d85:tc_ctl_ tclass+0x3b5/0x400 [kernel] (inexact) 0xffffffff8172b336:rtnetlink_rcv_msg+0xe6/0x230 [kernel] (inexact) 0xffffffff81706bd7: __alloc_skb+0x87/0x1f0 [kernel] (inexact) 0xffffffff8172b250:rtnetlink_rcv_msg+0x0/0x230 [ Kernel] (inexact) 0xffffffff8174ee24:netlink_rcv_skb+0xa4/0xc0 [kernel] (inexact) 0xffffffff8172b248:rtnetlink_rcv+ 0x28/0x30 [kernel] (inexact) 0xffffffff8174e5da:netlink_unicast+0x12a/0x1b0 [kernel] (inexact) 0XFFFFFFFF8174EB01: netlink_sendmsg+0x4a1/0x5f0 [kernel] (inexact) 0xffffffff813912f1:aa_sock_msg_perm+0x61/0x150 [kernel] (inexact) 0xffffffff816fe098:sock_sendmsg+0x38/0x50 [kernel] (inexact) 0xffffffff816feb41: ___sys_sendmsg+0x281/0x290 [kernel ] (inexact) 0xffffffff8120018b:mem_cgroup_try_charge+0x6b/0x1b0 [kernel] (inexact) 0xffffffff8119dfd7:lru_cache_add _active_or_unevictable+0x27/0xa0 [kernel] (inexact) 0xffffffff811bf87a:handle_mm_fault+0xcaa/0x1820 [kernel] (inexact) 0xffffffff816ff491: __sys_sendmsg+0x51/0x90 [kernel] (inexact) 0xffffffff816ff4e2:sys_sendmsg+0x12/0x20 [kernel] (inexact) 0xffffffff818244f2:entry_syscall_64_fastpath+0x16/ 0x71 [kernel] (inexact)

In Qdisc, it was found that each creation of a category would result in a new qdisc created, and where would the Qdisc go?

Rt_netlink

4068 static int __net_init rtnetlink_net_init (struct net *net) 4069 {4070     struct sock *sk;4071     struct NETLINK_ Kernel_cfg cfg = {4072         . Groups     = rtnlgrp_max,4073         . Input      = rtnetlink_rcv,4074         . Cb_mutex   = &rtnl_mutex,4075         . Flags      = nl_cfg_f_nonroot_recv,4076     };4077 4078     sk = Netlink_kernel_create ( NET, Netlink_route, &cfg); 4079     if (!sk) 4080         return-enomem;4081     net->rtnl = sk;4082     Return 0;4083}

A protocol that registers such a network, and then this protocol specifically deals with the strategy of the Network transceiver packet

The Htb_qdisc_ops function is prototyped as follows:

1582 Static const struct QDISC_CLASS_OPSHtb_class_ops= {
1583. Graft = Htb_graft,
1584. Leaf = Htb_leaf,
1585. qlen_notify = Htb_qlen_notify,
1586. Get = Htb_get,
1587. put = Htb_put,
1588. Change = Htb_change_class,
1589. Delete = Htb_delete,
1590. Walk = Htb_walk,
1591. Tcf_chain = Htb_find_tcf,
1592. Bind_tcf = Htb_bind_filter,
1593. Unbind_tcf = Htb_unbind_filter,
1594. Dump = Htb_dump_class,
1595. Dump_stats = Htb_dump_class_stats,
1596};
1597
1598 static struct Qdisc_opsHtb_qdisc_ops__read_mostly = {
1599. Cl_ops = &htb_class_ops,
The. id = "HTB",
1601. priv_size = sizeof (struct htb_sched),
1602. Enqueue = Htb_enqueue,
1603. dequeue = Htb_dequeue,
1604. Peek = qdisc_peek_dequeued,
1605. init = Htb_init,
1606. reset = Htb_reset,
1607. Destroy = Htb_destroy,
1608. Dump = Htb_dump,
1609. Owner = This_module,
1610};

Tc_ctl_tclass is the treatment of class!!!!!

How does a child queue relate to the parent queue? For the HTB algorithm, how exactly is this tree managed?

207 static struct Htb_class *htb_classify (struct sk_buff *skb, struct Qdisc *sch,
How to Htb_classify, put the packet in the corresponding queue.

TC: Prostitution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.