Speed limit module functions

Source: Internet
Author: User

Note:

1: The isactive value of the userinfo table is not updated in real time, but when the userinfo table is full, the isactive value of the table is updated only when 1 = isactive is not found in the new SKB and the MAC address is the same.

 

1: int usermgmt_init (void)

Call: called during system initialization.

Purpose:

(1) allocate 8 bwlimitrule spaces. The initial address is bwlimitrule;

Bwlimitrule [user_mgmt_max_bw_limit_rule];

(2) Allocate space for 100 userinfo entries. The initial address is userinfo;

Userinfo [user_mgmt_max_user_num];

(3) value assignment of the hook address of the account function of the speed limit module:

Usermgmt_isallowforward_hook = usermgmt_isallowforward;

(4) setmark_hook address assignment:

Usermgmt_setmark_hook = usermgmt_setmark;

 

2: int usermgmt_enable (INT isbandwidthlimitenable );

Call: board_ioctl is called when the speed limit function is enabled and disabled;

Purpose:

(1) When the speed limit function is Enabled: usermgmt_isallowforward_hook = usermgmt_isallowforward;

(2) When the speed limit function is disabled: usermgmt_isallowforward_hook = NULL;

 

3: int usermgmt_isallowforward (struct sk_buff * SKB; int direction; unsigned long pktjiffies );

Parameter description: (1) SKB;

(2) ction; packet direction, 1-uplink, 0-downlink;

(3) unsigned long pktjiffies; Package time, ptkjiffies.

Call: when the speed limit function is enabled, it is called in kernel and Dev. C.

Purpose:

Isfound = 0;

Firstunusedentry =-1;

(1) For (traverses 100 userinfo entries)

If (1 = userinfo [I]. isactive)

{

If (skbmac and userinfo [I]. Mac are the same)

{

Isfound = 1;

Break;

Indicates that the corresponding entry is found in the currently active userinfo entry.

}

}

Else (0 = userinfo [I]. isactive)

{

Firstunusedentry = I;

(Can it be optimized here? Break)

}

(2) If (0 = isfound, indicating that 1 = isactive and the MAC address is not found)

{

If (-1 = firstunusedentry) indicates that no entry = isactive is found in the traversal of (1 ).

{

Updating the status of the userinfo table sets isactive for a long time without entry (5S) to 0, and after updating the table

The value of the entry 0 = isactive is returned to firstunusedentry. If no value 0 = isactive

-1 is returned.

Firstunusedentry = usermgmt_refreshuserstatus ();

}

If (-1! = Firstunusedentry) indicates that in the userinfo table, there is no 0! = Isactive and the MAC address is the same

0 = isactive userinfo entry.

{

Because it is the first package of the new entry, SKB and return 0 are forwarded after the userinfo [firstunusedentry] status is updated;

Userinfoptr = & userinfo [firstunusedentry];

Userinfoptr-> isactive = 1;

Usermgmt_getbwlimitbyifname (& (userinfoptr-> upbwlimit ),

& (Userinfoptr-> downbwlimit ),
SKB-> Dev-> name );

}

}

 

Speed limit module functions

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.