Commit 41572e0c authored by Maria Matejka's avatar Maria Matejka
Browse files

Merge commit 'f81702b7' into haugesund

parents 9dc1d778 f81702b7
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -425,6 +425,23 @@ filter_commit(struct config *new, struct config *old)
    }
}

void channel_filter_dump(const struct filter *f)
{
  if (f == FILTER_ACCEPT)
    debug(" ALL");
  else if (f == FILTER_REJECT)
    debug(" NONE");
  else if (f == FILTER_UNDEF)
    debug(" UNDEF");
  else if (f->sym) {
    ASSERT(f->sym->filter == f);
    debug(" named filter %s", f->sym->name);
  } else {
    debug("\n");
    f_dump_line(f->root, 2);
  }
}

void filters_dump_all(void)
{
  struct symbol *sym;
@@ -444,19 +461,10 @@ void filters_dump_all(void)
	  struct channel *c;
	  WALK_LIST(c, sym->proto->proto->channels) {
	    debug(" Channel %s (%s) IMPORT", c->name, net_label[c->net_type]);
	    if (c->in_filter == FILTER_ACCEPT)
	      debug(" ALL\n");
	    else if (c->in_filter == FILTER_REJECT)
	      debug(" NONE\n");
	    else if (c->in_filter == FILTER_UNDEF)
	      debug(" UNDEF\n");
	    else if (c->in_filter->sym) {
	      ASSERT(c->in_filter->sym->filter == c->in_filter);
	      debug(" named filter %s\n", c->in_filter->sym->name);
	    } else {
	    channel_filter_dump(c->in_filter);
	    debug(" EXPORT", c->name, net_label[c->net_type]);
	    channel_filter_dump(c->out_filter);
	    debug("\n");
	      f_dump_line(c->in_filter->root, 2);
	    }
	  }
	}
    }
+3 −1
Original line number Diff line number Diff line
@@ -851,8 +851,10 @@ CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]])
{ neigh_dump_all(); cli_msg(0, ""); } ;
CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]])
{ rta_dump_all(); cli_msg(0, ""); } ;
CF_CLI(DUMP ROUTES,,, [[Dump routing table]])
CF_CLI(DUMP ROUTES,,, [[Dump routes]])
{ rt_dump_all(); cli_msg(0, ""); } ;
CF_CLI(DUMP TABLES,,, [[Dump table connections]])
{ rt_dump_hooks_all(); cli_msg(0, ""); } ;
CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]])
{ protos_dump_all(); cli_msg(0, ""); } ;
CF_CLI(DUMP FILTER ALL,,, [[Dump all filters in linearized form]])

nest/limit.h

0 → 100644
+49 −0
Original line number Diff line number Diff line
/*
 *	BIRD Internet Routing Daemon -- Limits
 *
 *	(c) 1998--2000 Martin Mares <mj@ucw.cz>
 *	(c) 2021 Maria Matejka <mq@jmq.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_LIMIT_H_
#define _BIRD_LIMIT_H_

struct limit {
  u32 max;
  u32 count;
  int (*action)(struct limit *, void *data);
};

static inline int limit_do_action(struct limit *l, void *data)
{
  return l->action ? l->action(l, data) : 1;
}

static inline int limit_push(struct limit *l, void *data)
{
  if ((l->count >= l->max) && limit_do_action(l, data))
    return 1;

  l->count++;
  return 0;
}

static inline void limit_pop(struct limit *l)
{
  --l->count;
}

static inline void limit_reset(struct limit *l)
{
  l->count = 0;
}

static inline void limit_update(struct limit *l, void *data, u32 max)
{
  if (l->count > (l->max = max))
    limit_do_action(l, data);
}

#endif
Loading