From f71f75f39b240b4306ad500e7f50cfc138458192 Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Sun, 23 Mar 2008 23:53:57 +0100 Subject: [PATCH] police, implement overhead parameter parsing. 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 Signed-off-by: Stephen Hemminger --- tc/m_police.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tc/m_police.c b/tc/m_police.c index 46c785b6..8fa63ad6 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 [/NOTEXCEEDACT] \n"); fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed [/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;