public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <jdb@comx.dk>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH 5/5] [IPROUTE2] For police, implement overhead parameter parsing.
Date: Sun, 23 Mar 2008 23:53:57 +0100	[thread overview]
Message-ID: <1206312837.15884.39.camel@localhost.localdomain> (raw)
In-Reply-To: <1206312248.15884.26.camel@localhost.localdomain>


For police, implement overhead parameter parsing.

The change is ABI (Application Binary Interface) backward compatible
with older kernels, but will first have effect from kernel 2.6.24.

Signed-off-by: Jesper Dangaard Brouer <hawk@comx.dk>
---
 tc/m_police.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/tc/m_police.c b/tc/m_police.c
index 46c785b..8fa63ad 100644
--- a/tc/m_police.c
+++ b/tc/m_police.c
@@ -35,7 +35,7 @@ struct action_util police_action_util = {
 static void usage(void)
 {
 	fprintf(stderr, "Usage: ... police rate BPS burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ]\n");
-	fprintf(stderr, "                [ peakrate BPS ] [ avrate BPS ]\n");
+	fprintf(stderr, "                [ peakrate BPS ] [ avrate BPS ] [ overhead BYTES ]\n");
 	fprintf(stderr, "                [ ACTIONTERM ]\n");
 	fprintf(stderr, "Old Syntax ACTIONTERM := action <EXCEEDACT>[/NOTEXCEEDACT] \n");
 	fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed <EXCEEDACT>[/NOTEXCEEDACT] \n");
@@ -133,6 +133,7 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_
 	__u32 avrate = 0;
 	int presult = 0;
 	unsigned buffer=0, mtu=0, mpu=0;
+	unsigned short overhead;
 	int Rcell_log=-1, Pcell_log = -1;
 	struct rtattr *tail;
 
@@ -234,6 +235,11 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_
 				fprintf(stderr, "Illegal \"action\"\n");
 				return -1;
 			}
+		} else if (matches(*argv, "overhead") == 0) {
+			NEXT_ARG();
+			if (get_u16(&overhead, *argv, 10)) {
+				explain1("overhead"); return -1;
+			}
 		} else if (strcmp(*argv, "help") == 0) {
 			usage();
 		} else {
@@ -263,6 +269,7 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_
 
 	if (p.rate.rate) {
 		p.rate.mpu = mpu;
+		p.rate.overhead = overhead;
 		if (tc_calc_rtable(&p.rate, rtab, Rcell_log, mtu) < 0) {
 			fprintf(stderr, "TBF: failed to calculate rate table.\n");
 			return -1;
@@ -272,6 +279,7 @@ int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_
 	p.mtu = mtu;
 	if (p.peakrate.rate) {
 		p.peakrate.mpu = mpu;
+		p.peakrate.overhead = overhead;
 		if (tc_calc_rtable(&p.peakrate, ptab, Pcell_log, mtu) < 0) {
 			fprintf(stderr, "POLICE: failed to calculate peak rate table.\n");
 			return -1;
@@ -344,6 +352,7 @@ print_police(struct action_util *a, FILE *f, struct rtattr *arg)
 		fprintf(f, "/%s ", police_action_n2a(*(int*)RTA_DATA(tb[TCA_POLICE_RESULT]), b1, sizeof(b1)));
 	} else
 		fprintf(f, " ");
+	fprintf(f, "overhead %ub ", p->rate.overhead);
 	fprintf(f, "\nref %d bind %d\n",p->refcnt, p->bindcnt);
 
 	return 0;
-- 
1.5.3



  parent reply	other threads:[~2008-03-23 23:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1206312248.15884.26.camel@localhost.localdomain>
2008-03-23 22:50 ` [PATCH 3/5] [IPROUTE2] For CBQ, implement overhead parameter parsing Jesper Dangaard Brouer
2008-03-23 22:52 ` [PATCH 4/5] [IPROUTE2] CBQ remember to doc usage of overhead parameter Jesper Dangaard Brouer
2008-03-23 22:53 ` Jesper Dangaard Brouer [this message]
2008-04-01 19:23 ` [PATCH 0/5] [IPROUTE2] Add overhead parameter for CBQ, TBF and police Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1206312837.15884.39.camel@localhost.localdomain \
    --to=jdb@comx.dk \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox