Re: [DCCP]: Add priority queuing policy

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

 



Please revise this patch with regard to CodingStyle -- checkpatch gave
38 errors here.

| --- a/net/dccp/dccp.h
| +++ b/net/dccp/dccp.h
| @@ -330,10 +330,16 @@ struct dccp_skb_cb {
|  	__u16 dccpd_opt_len;
|  	__u64 dccpd_seq;
|  	__u64 dccpd_ack_seq;
| +	char  dccpd_policy[16];
|  };
|  
|  #define DCCP_SKB_CB(__skb) ((struct dccp_skb_cb *)&((__skb)->cb[0]))
|  
| +struct dccp_policy_prio {
| +	s8	priority;
| +};
| +#define SKB_PRIO(__skbcb) ((struct dccp_policy_prio *)&((__skbcb)->dccpd_policy[0]))
| +
There is an indirection here which is problematic:
 * it pre-allocates 16 bytes but currently only uses one byte
 * with regard to the recent patch for IPv4/v6 parameters, the skb_cb
   space gets smaller, and there is no test such as BUILD_BUG_ON
 * the element should be the struct (can remain anonymous), so there would not be
   the double-indirection in the SKB_PRIO typecast (which is also too long)

| --- /dev/null
| +++ b/net/dccp/qpolicy_prio.c
| @@ -0,0 +1,88 @@
| +/*
| + *  net/dccp/qpolicy_prio.c
| + *
| + *  An implementation of the DCCP protocol
| + *
| + *  Copyright (c) 2008 Tomasz Grobelny <tomasz@xxxxxxxxxxxxxxxxxxxxxxx>
| + *
| + *  This program is free software; you can redistribute it and/or
| + *  modify it under the terms of the GNU General Public License v2
| + *  as published by the Free Software Foundation.
| + */
| +
| +#include "qpolicy.h"
| +#define POLICY_ID 1
| +
==> General comment: the functions in this file can also all be declared
                     `static', since they are not used externally.
| +struct sk_buff *dccp_queue_get_worst(struct sk_buff_head *list)
| +{
| +	int i, worstp = -128;
| +	struct sk_buff *curr=(struct sk_buff*)list;
| +	struct sk_buff *worst=NULL;
| +	struct dccp_skb_cb *dcb;
| +	for(i=0;i<list->qlen;i++)
| +	{
For structs, ifs, for/while loops, please place curly bracket on same line, cf. CodingStyle.	
| +		curr=curr->next;
| +		dcb = DCCP_SKB_CB(curr);
| +		if(SKB_PRIO(dcb)->priority > worstp)
| +		{
| +			worstp=SKB_PRIO(dcb)->priority;
| +			worst=curr;
| +		}
| +	}
| +	return worst;
| +}
| +
| +void prio_push(struct sock *sk, struct sk_buff *skb, void* control, __kernel_size_t controllen)
| +{
| +	struct dccp_policy_prio *dcp = (struct dccp_policy_prio *)control;
| +	struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
| +	SKB_PRIO(dcb)->priority = 127;
| +	if(dcp)
| +		memcpy(SKB_PRIO(dcb), dcp, min(sizeof(struct dccp_policy_prio), controllen));
| +	skb_queue_tail(&sk->sk_write_queue, skb);
| +	if(sk->sk_write_queue.qlen >= sysctl_dccp_tx_qlen)
| +	{
| +		struct sk_buff* worst=dccp_queue_get_worst(&sk->sk_write_queue);
| +		skb_unlink(worst, &sk->sk_write_queue);
| +		kfree_skb(worst);
| +	}
| +}
| +
| +/** no matter what we can push a packet into the queue => queue is never full */
| +int prio_full(struct sock *sk)
| +{
| +	return 0;
| +}
| +
| +struct sk_buff* prio_top(struct sock *sk)
| +{
| +	int i, bestp=127;
Please leave spaces between '='.
| +	struct sk_buff *curr=(struct sk_buff*)(&sk->sk_write_queue);
| +	struct sk_buff *best=NULL;
| +	struct dccp_skb_cb *dcb;
| +	for(i=0;i<sk->sk_write_queue.qlen;i++)
| +	{
| +		curr=curr->next;
| +		dcb = DCCP_SKB_CB(curr);
| +		if(SKB_PRIO(dcb)->priority < bestp)
| +		{
| +			bestp=SKB_PRIO(dcb)->priority;
| +			best=curr;
| +		}
| +	}
| +	return best;
| +}
| +
| +void prio_pop(struct sock *sk, struct sk_buff *skb)
| +{
| +	skb_unlink(skb, &sk->sk_write_queue);
| +}
| +
| +struct dccp_qpolicy_operations prio_policy_operations =
| +{
| +	.policy_id = POLICY_ID,
| +	.push = prio_push,
| +	.full = prio_full,
| +	.top = prio_top,
| +	.pop = prio_pop,
| +};


-- 


The University of Aberdeen is a charity registered in Scotland, No SC013683.

--
To unsubscribe from this list: send the line "unsubscribe dccp" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [IETF DCCP]     [Linux Networking]     [Git]     [Security]     [Linux Assembly]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux