Commit c461ab7e authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

Merge commit '76dd4730' into pim

parents df99c226 76dd4730
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
#include <libssh/libssh.h>
#endif

struct mif_group;
struct mif;

#ifdef HAVE_LIBSSH
struct ssh_sock {
    const char *username;		/* (Required) SSH user name */
@@ -105,6 +108,7 @@ int sk_join_group(sock *s, ip_addr maddr); /* Join multicast group on sk iface *
int sk_leave_group(sock *s, ip_addr maddr);	/* Leave multicast group on sk iface */
int sk_set_router_alert(sock *s, int ra);
int sk_setup_broadcast(sock *s);
int sk_setup_igmp(sock *s, struct mif_group *grp, struct mif *mif);
int sk_set_ttl(sock *s, int ttl);	/* Set transmit TTL for given socket */
int sk_set_min_ttl(sock *s, int ttl);	/* Set minimal accepted TTL for given socket */
int sk_set_md5_auth(sock *s, ip_addr local, ip_addr remote, struct iface *ifa, char *passwd, int setkey);
+68 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "nest/protocol.h"
#include "nest/cli.h"
#include "lib/resource.h"
#include "lib/socket.h"
#include "lib/string.h"
#include "conf/conf.h"
#include "sysdep/unix/krt.h"
@@ -723,6 +724,10 @@ if_init(void)
 *	Multicast Ifaces
 */

struct mkrt_proto;
void mkrt_register_mif(struct mkrt_proto *p, struct mif *mif);
void mkrt_unregister_mif(struct mkrt_proto *p, struct mif *mif);

static struct mif_group *
mif_get_group(void)
{
@@ -754,6 +759,9 @@ mif_get(struct mif_group *grp, struct iface *iface)
  grp->mifs[mif->index] = mif;
  MIFS_SET(mif, grp->indexes);

  if (grp->owner)
    mkrt_register_mif((struct mkrt_proto *) grp->owner, mif);

  return mif;
}

@@ -763,6 +771,9 @@ mif_free(struct mif_group *grp, struct mif *mif)
  if (--mif->uc)
    return;

  if (grp->owner)
    mkrt_unregister_mif((struct mkrt_proto *) grp->owner, mif);

  node *n;
  WALK_LIST_FIRST(n, mif->sockets)
    rem_node(n);
@@ -773,6 +784,63 @@ mif_free(struct mif_group *grp, struct mif *mif)
  mb_free(mif);
}

/*
 * Move socket from global list to MIF based lists. These lists are used to
 * deliver IGMP messages by mif_forward_igmp().
 */
void
mif_listen_igmp(struct mif_group *grp, struct mif *mif, sock *s)
{
  rem_node(&s->n);
  add_tail(mif ? &mif->sockets : &grp->sockets, &s->n);
}

/*
 * Forward a packet from one socket to another. Emulates the receiving routine.
 * Socket is in the same state as if it received the packet itself, but must not
 * modify it to preserve it for others.
 */
static void
mif_do_forward(sock *src, sock *dst, int len)
{
  if (!dst->rx_hook)
    return;

  dst->faddr = src->faddr;
  dst->laddr = src->laddr;
  dst->lifindex = src->lifindex;

  dst->rbuf = src->rbuf;
  dst->rpos = src->rpos;
  dst->rbsize = src->rbsize;

  dst->rx_hook(dst, len);

  dst->faddr = dst->laddr = IPA_NONE;
  dst->lifindex = 0;

  dst->rbuf = dst->rpos = NULL;
  dst->rbsize = 0;
}

/*
 * Forward a packet to all sockets registered for given MIF. It is used to
 * deliver IGMP messages from the MRT control socket to IGMP sockets.
 */
void
mif_forward_igmp(struct mif_group *grp, struct mif *mif, sock *src, int len)
{
  node *n, *nn;
  sock *dst;

  WALK_LIST2_DELSAFE(dst, n, nn, grp->sockets, n)
    mif_do_forward(src, dst, len);

  if (mif)
    WALK_LIST2_DELSAFE(dst, n, nn, mif->sockets, n)
      mif_do_forward(src, dst, len);
}

/*
 *	Interface Pattern Lists
 */
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct mif_group {
  uint indexes;
  uint uc;				/* Use count, not implemented */
  list sockets;				/* Listening global IGMP sockets */
  struct proto *owner;			/* MKernel responsible for MIFs */
  struct mif *mifs[MIFS_MAX];
};

+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
struct ea_list;
struct protocol;
struct proto;
struct channel;
struct rte_src;
struct symbol;
struct filter;
@@ -296,7 +297,7 @@ rte *rte_find(net *net, struct rte_src *src);
rte *rte_get_temp(struct rta *);
void rte_update2(struct channel *c, const net_addr *n, rte *new, struct rte_src *src);
/* rte_update() moved to protocol.h to avoid dependency conflicts */
int rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter);
int rt_examine(struct channel *c, net_addr *a, void (*cb)(struct proto *, void *, rte *), void *data);
rte *rt_export_merged(struct channel *c, net *net, rte **rt_free, struct ea_list **tmpa, linpool *pool, int silent);
void rt_refresh_begin(rtable *t, struct channel *c);
void rt_refresh_end(rtable *t, struct channel *c);
+8 −3
Original line number Diff line number Diff line
@@ -1406,9 +1406,10 @@ rte_discard(rte *old) /* Non-filtered route deletion, used during garbage collec

/* Check rtable for best route to given net whether it would be exported do p */
int
rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter)
rt_examine(struct channel *c, net_addr *a, void (*cb)(struct proto *, void *, rte *), void *data)
{
  net *n = net_find(t, a);
  struct proto *p = c->proto;
  net *n = net_find(c->table, a);
  rte *rt = n ? n->routes : NULL;

  if (!rte_is_valid(rt))
@@ -1420,7 +1421,11 @@ rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter)
  ea_list *tmpa = rte_make_tmp_attrs(rt, rte_update_pool);
  int v = p->import_control ? p->import_control(p, &rt, &tmpa, rte_update_pool) : 0;
  if (v == RIC_PROCESS)
    v = (f_run(filter, &rt, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) <= F_ACCEPT);
    v = (f_run(c->out_filter, &rt, &tmpa, rte_update_pool, FF_FORCE_TMPATTR) <= F_ACCEPT);

  /* Call callback when route is exported */
  if (cb && (v > 0))
    cb(p, data, rt);

   /* Discard temporary rte */
  if (rt != n->routes)
Loading