Commit 76dd4730 authored by Ondřej Hlavatý's avatar Ondřej Hlavatý
Browse files

Added the mkernel protocol

parent 76baa8b3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ extern int sk_priority_control; /* Suggested priority for control traffic, shou
#define SK_MAGIC	7	   /* Internal use by sysdep code */
#define SK_UNIX_PASSIVE	8
#define SK_UNIX		9
#define SK_IGMP		10	   /* ?  -  ?  -  ?  ?   ?	*/

/*
 *	Socket subtypes
@@ -146,6 +147,11 @@ extern int sk_priority_control; /* Suggested priority for control traffic, shou
 * per-packet basis using platform dependent options (but these are not
 * available in some corner cases). The first way is used when SKF_BIND is
 * specified, the second way is used otherwise.
 *
 *  SK_IGMP sockets are just IP sockets with IPPROTO_IGMP, but does not receive
 *  packets directly from kernel. Instead, bird forwards all packets received
 *  on multicast routing control socket to this socket internally. That means,
 *  all IGMP packets even for groups that noone is joined are received here.
 */

#endif
+6 −3
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ if_dump(struct iface *i)
    debug(" IGN");
  if (i->flags & IF_TMP_DOWN)
    debug(" TDOWN");
  if (i->flags & IF_VIFI_ASSIGNED)
    debug(" MR");
  debug(" MTU=%d\n", i->mtu);
  WALK_LIST(a, i->addrs)
    {
@@ -115,7 +117,7 @@ if_what_changed(struct iface *i, struct iface *j)
{
  unsigned c;

  if (((i->flags ^ j->flags) & ~(IF_UP | IF_SHUTDOWN | IF_UPDATED | IF_ADMIN_UP | IF_LINK_UP | IF_TMP_DOWN | IF_JUST_CREATED))
  if (((i->flags ^ j->flags) & ~(IF_UP | IF_SHUTDOWN | IF_UPDATED | IF_ADMIN_UP | IF_LINK_UP | IF_TMP_DOWN | IF_JUST_CREATED | IF_VIFI_ASSIGNED))
      || i->index != j->index)
    return IF_CHANGE_TOO_MUCH;
  c = 0;
@@ -131,7 +133,7 @@ if_what_changed(struct iface *i, struct iface *j)
static inline void
if_copy(struct iface *to, struct iface *from)
{
  to->flags = from->flags | (to->flags & IF_TMP_DOWN);
  to->flags = from->flags | (to->flags & (IF_TMP_DOWN | IF_VIFI_ASSIGNED));
  to->mtu = from->mtu;
}

@@ -780,10 +782,11 @@ if_show(void)
	type = "PtP";
      else
	type = "MultiAccess";
      cli_msg(-1004, "\t%s%s%s Admin%s Link%s%s%s MTU=%d",
      cli_msg(-1004, "\t%s%s%s%s Admin%s Link%s%s%s MTU=%d",
	      type,
	      (i->flags & IF_BROADCAST) ? " Broadcast" : "",
	      (i->flags & IF_MULTICAST) ? " Multicast" : "",
	      (i->flags & IF_VIFI_ASSIGNED) ? " MRoutable" : "",
	      (i->flags & IF_ADMIN_UP) ? "Up" : "Down",
	      (i->flags & IF_LINK_UP) ? "Up" : "Down",
	      (i->flags & IF_LOOPBACK) ? " Loopback" : "",
+8 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ struct iface {
  unsigned flags;
  unsigned mtu;
  unsigned index;			/* OS-dependent interface index */
  unsigned vifi;			/* VIF index for multicast routing */
  list addrs;				/* Addresses assigned to this interface */
  struct ifa *addr;			/* Primary address */
  list neighbors;			/* All neighbors on this interface */
@@ -47,6 +48,7 @@ struct iface {
#define IF_IGNORE 0x40			/* Not to be used by routing protocols (loopbacks etc.) */
#define IF_ADMIN_UP 0x80		/* Administrative up (e.g. IFF_UP in Linux) */
#define IF_LINK_UP 0x100		/* Link available (e.g. IFF_LOWER_UP in Linux) */
#define IF_VIFI_ASSIGNED 0x200		/* This device is set up for multicast routing */

#define IA_PRIMARY 0x10000		/* This address is primary */
#define IA_SECONDARY 0x20000		/* This address has been reported as secondary by the kernel */
@@ -101,6 +103,12 @@ struct iface *if_find_by_name(char *);
struct iface *if_get_by_name(char *);
void ifa_recalc_all_primary_addresses(void);

static inline int
if_get_vifi(struct iface *iface)
{
  return (iface && (iface->flags & IF_VIFI_ASSIGNED)) ? iface->vifi : -1;
}


/* The Neighbor Cache */

+2 −2
Original line number Diff line number Diff line
src := io.c krt.c log.c main.c random.c
src := io.c krt.c log.c main.c random.c mkrt.c
obj := $(src-o-files)
$(all-daemon)
$(cf-local)
$(conf-y-targets): $(s)krt.Y
$(conf-y-targets): $(s)krt.Y $(s)mkrt.Y
+18 −4
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@

#include "sysdep/unix/unix.h"
#include CONFIG_INCLUDE_SYSIO_H
#include "sysdep/unix/mkrt.h"

/* Maximum number of calls of tx handler for one socket in one
 * poll iteration. Should be small enough to not monopolize CPU by
@@ -825,7 +826,7 @@ sk_skip_ip_header(byte *pkt, int *len)
byte *
sk_rx_buffer(sock *s, int *len)
{
  if (sk_is_ipv4(s) && s->type == SK_IP)
  if (sk_is_ipv4(s) && (s->type == SK_IP || s->type == SK_IGMP))
    return sk_skip_ip_header(s->rbuf, len);
  else
    return s->rbuf;
@@ -1232,7 +1233,7 @@ sk_setup(sock *s)
    s->flags |= SKF_PKTINFO;

#ifdef CONFIG_USE_HDRINCL
  if (sk_is_ipv4(s) && (s->type == SK_IP) && (s->flags & SKF_PKTINFO))
  if (sk_is_ipv4(s) && (s->type == SK_IP || s->type == SK_IGMP) && (s->flags & SKF_PKTINFO))
  {
    s->flags &= ~SKF_PKTINFO;
    s->flags |= SKF_HDRINCL;
@@ -1270,7 +1271,7 @@ sk_setup(sock *s)
      if (sk_request_cmsg4_ttl(s) < 0)
	return -1;

    if ((s->type == SK_UDP) || (s->type == SK_IP))
    if ((s->type == SK_UDP) || (s->type == SK_IP) || (s->type == SK_IGMP))
      if (sk_disable_mtu_disc4(s) < 0)
	return -1;

@@ -1297,7 +1298,7 @@ sk_setup(sock *s)
      if (sk_request_cmsg6_ttl(s) < 0)
	return -1;

    if ((s->type == SK_UDP) || (s->type == SK_IP))
    if ((s->type == SK_UDP) || (s->type == SK_IP) || (s->type == SK_IGMP))
      if (sk_disable_mtu_disc6(s) < 0)
	return -1;

@@ -1458,6 +1459,11 @@ sk_open(sock *s)
    do_bind = 1;
    break;

  case SK_IGMP:
    af = AF_INET;
    s->dport = IPPROTO_IGMP;
    s->rbsize = 0; /* read buffer is shared */
    /* Fall thru */
  case SK_IP:
    fd = socket(af, SOCK_RAW, s->dport);
    bind_port = 0;
@@ -1538,6 +1544,12 @@ sk_open(sock *s)
    sk_alloc_bufs(s);
  }

  if (s->type == SK_IGMP)
    {
      mkrt_listen(s);
      return 0;
    }

  if (!(s->flags & SKF_THREAD))
    sk_insert(s);
  return 0;
@@ -1724,6 +1736,7 @@ sk_maybe_write(sock *s)

  case SK_UDP:
  case SK_IP:
  case SK_IGMP:
    {
      if (s->tbuf == s->tpos)
	return 1;
@@ -2112,6 +2125,7 @@ io_init(void)
  init_list(&sock_list);
  init_list(&global_event_list);
  krt_io_init();
  mkrt_io_init();
  init_times();
  update_times();
  boot_time = now;
Loading