[enable_libssh=try]
)
+AC_ARG_ENABLE([mpls-kernel],
+ [AS_HELP_STRING([--enable-mpls-kernel], [enable MPLS support in kernel protocol @<:@try@:>@])],
+ [],
+ [enable_mpls_kernel=try]
+)
+
AC_ARG_WITH([protocols],
[AS_HELP_STRING([--with-protocols=LIST], [include specified routing protocols @<:@all@:>@])],
[],
fi
fi
+if test "$enable_mpls_kernel" != no ; then
+ BIRD_CHECK_MPLS_KERNEL
+
+ if test "$bird_cv_mpls_kernel" = yes ; then
+ AC_DEFINE([HAVE_MPLS_KERNEL], [1], [Define to 1 if kernel is MPLS capable])
+ elif test "$enable_mpls_kernel" = yes ; then
+ AC_MSG_ERROR([Kernel MPLS support not found.])
+ fi
+
+ if test "$enable_mpls_kernel" = try ; then
+ enable_mpls_kernel="$bird_cv_mpls_kernel"
+ fi
+fi
+
all_protocols="$proto_bfd babel bgp ospf pipe radv rip $proto_rpki static"
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
AC_CHECK_HEADERS_ONCE([alloca.h syslog.h])
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
-AC_CHECK_HEADERS([linux/lwtunnel.h],
- [AC_DEFINE([HAVE_LWTUNNEL], [1], [Define to 1 if you have the <linux/lwtunnel.h> header file.])],
- [],
- [] dnl Force new AC_CHECK_HEADER semantics
-)
-
-AC_CHECK_MEMBERS([struct rtvia.rtvia_family],
- [AC_DEFINE([HAVE_STRUCT_RTVIA], [1], [Define to 1 if you have rtvia structure.])],
- [],
- [#include <linux/rtnetlink.h>]
-)
-
AC_C_BIGENDIAN(
[AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],
[AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])],
AC_MSG_RESULT([ Debugging: $enable_debug])
AC_MSG_RESULT([ POSIX threads: $enable_pthreads])
AC_MSG_RESULT([ Routing protocols: $protocols])
+AC_MSG_RESULT([ Kernel MPLS support: $enable_mpls_kernel])
AC_MSG_RESULT([ Client: $enable_client])
rm -f $objdir/.*-stamp
#include <asm/types.h>
#include <linux/if.h>
-#ifdef HAVE_LWTUNNEL
-#include <linux/lwtunnel.h>
-#else
-#include "sysdep/linux/lwtunnel.h"
-#endif
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#ifdef HAVE_MPLS_KERNEL
+#include <linux/lwtunnel.h>
+#endif
#ifndef MSG_TRUNC /* Hack: Several versions of glibc miss this one :( */
#define MSG_TRUNC 0x20
#define RTA_VIA 18
#endif
-#ifndef HAVE_STRUCT_RTVIA
-struct rtvia {
- unsigned short rtvia_family;
- u8 rtvia_addr[0];
-};
-#endif
-
#ifndef RTA_NEWDST
#define RTA_NEWDST 19
#endif
[RTA_ENCAP] = { 1, 0, 0 },
};
+#ifdef HAVE_MPLS_KERNEL
static struct nl_want_attrs encap_mpls_want[BIRD_RTA_MAX] = {
[RTA_DST] = { 1, 0, 0 },
};
+#endif
static struct nl_want_attrs rtm_attr_want4[BIRD_RTA_MAX] = {
[RTA_DST] = { 1, 1, sizeof(ip4_addr) },
[RTA_ENCAP] = { 1, 0, 0 },
};
+#ifdef HAVE_MPLS_KERNEL
static struct nl_want_attrs rtm_attr_want_mpls[BIRD_RTA_MAX] = {
[RTA_DST] = { 1, 1, sizeof(u32) },
[RTA_IIF] = { 1, 1, sizeof(u32) },
[RTA_VIA] = { 1, 0, 0 },
[RTA_NEWDST] = { 1, 0, 0 },
};
+#endif
static int
return ipa_from_ip6(rta_get_ip6(a));
}
+#ifdef HAVE_MPLS_KERNEL
static inline ip_addr rta_get_via(struct rtattr *a)
{
struct rtvia *v = RTA_DATA(a);
return mpls_get(RTA_DATA(a), RTA_PAYLOAD(a) & ~0x3, stack);
}
+#endif
struct rtattr *
nl_add_attr(struct nlmsghdr *h, uint bufsize, uint code, const void *data, uint dlen)
nl_add_attr_ip6(h, bufsize, code, ipa_to_ip6(ipa));
}
+#ifdef HAVE_MPLS_KERNEL
static inline void
nl_add_attr_mpls(struct nlmsghdr *h, uint bufsize, int code, int len, u32 *stack)
{
nl_close_attr(h, nest);
}
+#endif
static inline struct rtnexthop *
nl_open_nexthop(struct nlmsghdr *h, uint bufsize)
}
static inline void
-nl_add_nexthop(struct nlmsghdr *h, uint bufsize, struct nexthop *nh, int af)
+nl_add_nexthop(struct nlmsghdr *h, uint bufsize, struct nexthop *nh, int af UNUSED)
{
+#ifdef HAVE_MPLS_KERNEL
if (nh->labels > 0)
if (af == AF_MPLS)
nl_add_attr_mpls(h, bufsize, RTA_NEWDST, nh->labels, nh->label);
nl_add_attr_via(h, bufsize, nh->gw);
else
nl_add_attr_ipa(h, bufsize, RTA_GATEWAY, nh->gw);
+#else
+
+ if (ipa_nonzero(nh->gw))
+ nl_add_attr_ipa(h, bufsize, RTA_GATEWAY, nh->gw);
+#endif
}
static void
else
rv->gw = IPA_NONE;
+#ifdef HAVE_MPLS_KERNEL
if (a[RTA_ENCAP_TYPE])
- {
- if (rta_get_u16(a[RTA_ENCAP_TYPE]) != LWTUNNEL_ENCAP_MPLS) {
- log(L_WARN "KRT: Unknown encapsulation method %d in multipath", rta_get_u16(a[RTA_ENCAP_TYPE]));
- return NULL;
- }
-
- struct rtattr *enca[BIRD_RTA_MAX];
- nl_attr_len = RTA_PAYLOAD(a[RTA_ENCAP]);
- nl_parse_attrs(RTA_DATA(a[RTA_ENCAP]), encap_mpls_want, enca, sizeof(enca));
- rv->labels = rta_get_mpls(enca[RTA_DST], rv->label);
- break;
+ {
+ if (rta_get_u16(a[RTA_ENCAP_TYPE]) != LWTUNNEL_ENCAP_MPLS) {
+ log(L_WARN "KRT: Unknown encapsulation method %d in multipath", rta_get_u16(a[RTA_ENCAP_TYPE]));
+ return NULL;
}
+ struct rtattr *enca[BIRD_RTA_MAX];
+ nl_attr_len = RTA_PAYLOAD(a[RTA_ENCAP]);
+ nl_parse_attrs(RTA_DATA(a[RTA_ENCAP]), encap_mpls_want, enca, sizeof(enca));
+ rv->labels = rta_get_mpls(enca[RTA_DST], rv->label);
+ break;
+ }
+#endif
+
len -= NLMSG_ALIGN(nh->rtnh_len);
nh = RTNH_NEXT(nh);
r->r.rtm_dst_len = net_pxlen(net->n.addr);
r->r.rtm_protocol = RTPROT_BIRD;
r->r.rtm_scope = RT_SCOPE_NOWHERE;
+#ifdef HAVE_MPLS_KERNEL
if (p->af == AF_MPLS)
{
u32 label = net_mpls(net->n.addr);
nl_add_attr_mpls(&r->h, rsize, RTA_DST, 1, &label);
}
else
+#endif
nl_add_attr_ipa(&r->h, rsize, RTA_DST, net_prefix(net->n.addr));
/*
net_fill_ip6(&dst, IP6_NONE, 0);
break;
+#ifdef HAVE_MPLS_KERNEL
case AF_MPLS:
if (!nl_parse_attrs(RTM_RTA(i), rtm_attr_want_mpls, a, sizeof(a)))
return;
net_fill_mpls(&dst, rta_mpls_stack[0]);
break;
+#endif
default:
return;
return;
}
- if ((i->rtm_family != AF_MPLS) && a[RTA_GATEWAY] || (i->rtm_family == AF_MPLS) && a[RTA_VIA])
+ if ((i->rtm_family != AF_MPLS) && a[RTA_GATEWAY]
+#ifdef HAVE_MPLS_KERNEL
+ || (i->rtm_family == AF_MPLS) && a[RTA_VIA]
+#endif
+ )
{
+#ifdef HAVE_MPLS_KERNEL
if (i->rtm_family == AF_MPLS)
ra->nh.gw = rta_get_via(a[RTA_VIA]);
else
+#endif
ra->nh.gw = rta_get_ipa(a[RTA_GATEWAY]);
/* Silently skip strange 6to4 routes */
return;
}
+#ifdef HAVE_MPLS_KERNEL
int labels = 0;
if ((i->rtm_family == AF_MPLS) && a[RTA_NEWDST] && !ra->nh.next)
labels = rta_get_mpls(a[RTA_NEWDST], ra->nh.label);
}
else
ra->nh.labels = labels;
+#endif
rte *e = rte_get_temp(ra);
e->net = net;
log(L_DEBUG "nl_scan_fire: Unknown packet received (type=%d)", h->nlmsg_type);
nl_parse_end(&s);
+#ifdef HAVE_MPLS_KERNEL
nl_parse_begin(&s, 1, 1);
nl_request_dump(AF_MPLS, RTM_GETROUTE);
while (h = nl_get_scan())
else
log(L_DEBUG "nl_scan_fire: Unknown packet received (type=%d)", h->nlmsg_type);
nl_parse_end(&s);
+#endif
}
/*