Function

int qsize_enqueue (struct sk_buff * skb, struct Qdisc * sch)

Arguments

skb
A socket buffer containing a packet and other info
sch
The scheduler instance to place the skbuff into

Description

Once an instance of the scheduler has been created, this function is called whenever a packet is to be sent through the scheduler. We place the packet into our internal queue (one per instance), ready to be removed when qsize_dequeue is called. No modifications are made to the skbuff/packet at this point.

The following statistics are recorded

- backlog - length of queue (bytes and packets)

If the packet would place the queue over the limit, as specified by the limit option, it will be dropped. This is again recorded in the statistics.


Function

int qsize_requeue (struct sk_buff * skb, struct Qdisc * sch)

Arguments

skb
The socket buffer to be put back in the queue
sch
The scheduler instance it is to be placed into

Description

If a packet has to be placed back into the queue for any reason, this function will be called. We put the packet at the head of the queue, so that it will be dequeued next. No change is made to the statistics, other than the length of the queue.

Function

u_int16_t cheat_check (u_int32_t oldvalinv, u_int32_t newval, u_int16_t oldcheck)

Arguments

oldvalinv
The previous 32-bit value stored at some location
newval
The 32-bit value which has replaced the old value
oldcheck
The checksum of the packet with the old value

Description

This function is used when updating the checksum of a packet we have modified. It is important to use this rather than recalculating the entire checksum, in case the previous checksum was invalid. In that case, we must take care not to make it correct.

Function

struct sk_buff * qsize_dequeue (struct Qdisc * sch)

Arguments

sch
The instance of the scheduler from which a packet is desired

Description

This function retrieves the next packet to be sent. It also, if possible, modifies the packet so that it contains the p(q) TCP option. This is stored as option number 92, and it takes up 4 bytes. Because of this, it can only be included on packets which are 4 bytes or more smaller than the MTU of the device they're being sent on. Even so, this may cause troubles with Path-MTU discovery.

If the packet is modified, the checksum will be recalculated.

Packets which are too big (> MTU - 4) will be passed through without modification. They will be recorded as having passed through, but not modified.

Pseudocode

if (queue is empty) return NULL if (next packet is not IP and TCP) return it if (skb does not have enough tailroom, but packet can be grown) make room in the skb and insert zeroes at beginning of option if (packet can be grown): Fill in zeroes with option data Recalculate tcp checksum Recalculate ip checksum Increase stats for packets modified return the packet

Function

int qsize_drop (struct Qdisc * sch)

Arguments

sch
The queue from which a packet is to be dropped

Description

The packet at the tail of the queue is removed, and its memory freed. If the queue was already empty, nothing is done.

Function

void qsize_reset (struct Qdisc * sch)

Arguments

sch
The queue which is to be reset

Description

This function resets a queue back to its initial state. The queue is purged, and statistics reseta. The queue will now be empty.

Function

int qsize_init (struct Qdisc * sch, struct rtattr * opt)

Arguments

sch
The instnance to be initialised
opt
Any options to be used

Description

When a scheduler is added by running the tc command, this function is called to initialise the queue. Here we set the constants used to calculate p(q) and other variables, such as the length of the queue.

It also ensures the module will not be unloaded until all instances have been destroyed.


Function

void qsize_destroy (struct Qdisc * sch)

Arguments

sch
The instance of the scheduler to destroy

Description

This function frees all memory being used by the scheduler.

FIXME

We don't seem to actually free any memory!!

Function

int qsize_dump (struct Qdisc * sch, struct sk_buff * skb)

Arguments

sch
The qdisc to dump statistics for
skb
The netlink skbuff to return the results in

Function

int procfile_read (char * page, char ** start, off_t offset, int buffer_length, int * eof, void * data)

Arguments

page
unused
start
The pointer to save the location of our custom buffer to so that it can be found for printing.
offset
The offset from within the file for which data is required. If this is non-zero, we return nothing
buffer_length
The length of the memory given
eof
unused
data
unused

Description

When called, we create our own buffer, and fill it with information on all the qdisc instances. This uses the instances array the module keeps internally.

Function

int init_module ( void)

Arguments

void
no arguments

Description

Performs the following functions

- Checks that the mandatory maxrate parameter was given. Fails to load otherwise - Creates the entry for the file /proc/net/fcm_queue - Initialises the instances array - Registers as a qdisc

Function

void cleanup_module ( void)

Arguments

void
no arguments

Description

Performs the following functions - Removes the file /proc/net/fcm_queue - Unregisters as a qdisc