Commit 2bbc3083 authored by Ondrej Zajicek's avatar Ondrej Zajicek
Browse files

Store protocol config size inside protocol structure

Make proto_config_new() use this info instead of supplied size.

Thanks to Alexander V. Chernikov for the patch.
parent 374917ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ tos:
CF_ADDTO(proto, dev_proto '}')

dev_proto_start: proto_start DIRECT {
     this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1);
     this_proto = proto_config_new(&proto_device, $1);
     init_list(&DIRECT_CFG->iface_list);
   }
 ;
+2 −3
Original line number Diff line number Diff line
@@ -245,7 +245,6 @@ proto_free_ahooks(struct proto *p)
/**
 * proto_config_new - create a new protocol configuration
 * @pr: protocol the configuration will belong to
 * @size: size of the structure including generic data
 * @class: SYM_PROTO or SYM_TEMPLATE
 *
 * Whenever the configuration file says that a new instance
@@ -262,9 +261,9 @@ proto_free_ahooks(struct proto *p)
 * initialized during protos_commit()).
 */
void *
proto_config_new(struct protocol *pr, unsigned size, int class)
proto_config_new(struct protocol *pr, int class)
{
  struct proto_config *c = cfg_allocz(size);
  struct proto_config *c = cfg_allocz(pr->config_size);

  if (class == SYM_PROTO)
    add_tail(&new_config->protos, &c->n);
+8 −7
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ struct protocol {
  int name_counter;			/* Counter for automatic name generation */
  int attr_class;			/* Attribute class known to this protocol */
  int multitable;			/* Protocol handles all announce hooks itself */
  unsigned preference;			/* Default protocol preference */
  uint preference;			/* Default protocol preference */
  uint config_size;			/* Size of protocol config */

  void (*preconfig)(struct protocol *, struct config *);	/* Just before configuring */
  void (*postconfig)(struct proto_config *);			/* After configuring each instance */
@@ -239,7 +240,7 @@ struct proto_spec {


void *proto_new(struct proto_config *, unsigned size);
void *proto_config_new(struct protocol *, unsigned size, int class);
void *proto_config_new(struct protocol *, int class);
void proto_copy_config(struct proto_config *dest, struct proto_config *src);
void proto_request_feeding(struct proto *p);

+2 −1
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ struct protocol proto_device = {
  .name = 		"Direct",
  .template = 		"direct%d",
  .preference = 	DEF_PREF_DIRECT,
  .config_size =	sizeof(struct rt_dev_config),
  .init = 		dev_init,
  .reconfigure = 	dev_reconfigure,
  .copy_config = 	dev_copy_config
+1 −0
Original line number Diff line number Diff line
@@ -1112,6 +1112,7 @@ bfd_show_sessions(struct proto *P)
struct protocol proto_bfd = {
  .name =		"BFD",
  .template =		"bfd%d",
  .config_size =	sizeof(struct bfd_config),
  .init =		bfd_init,
  .start =		bfd_start,
  .shutdown =		bfd_shutdown,
Loading