Re: How do I publish default router preferences using rad?

2019-08-25 Thread Caleb Callaway
I want to enable a scenario similar to what's described in
https://tools.ietf.org/html/rfc4191#section-5.1

I run local network services for which I want a stable, publicly routed
prefix, but my ISP's delegated prefix isn't static. I've setup a
Hurricane Electric IPv6 tunnel to get a static prefix along side the
dynamic, ISP-delegated prefix; https://github.com/cqcallaw/openbsd-router
has details.

Everything is functionally correct with the source-based routing
configuration described in the docs, but the HE tunnel is necessarily
slow because of the overhead incurred by the 6in4 tunnel. Connections
are faster if my multihomed hosts prefer the native route for traffic
that doesn't require use of the tunnel.

I had patched rad to experiment with route preferences as a solution to
this performance issue, but my local hosts don't seem to honor the
advertised route preferences. I'm still researching what's required on
the client side for route preferences to be honored.

On Sun, Aug 18, 2019 at 4:28 AM Florian Obser  wrote:

> I'm curious, how are you using the router preference, could you tell
> us a bit more about your network topology?
> Also, what clients pay attention to it and how are they using it?
>
> Same goes for the route option, are you aware of clients using it?
>
> Thanks,
> Florian
>
> On Sat, Aug 17, 2019 at 08:09:54PM -0700, Caleb Callaway wrote:
> > If it interests anyone, I've also implemented the route option
> > described in https://tools.ietf.org/html/rfc4191#section-2.3
> >
> > I find sharing patches via this mailing list particularly unwieldy,
> > so I've pushed my work to a git branch at
> > https://github.com/cqcallaw/src/tree/rfc-4191
> >
> > On Wed, Aug 7, 2019 at 11:27 PM Caleb 
> wrote:
> > >
> > > Thank you for the code and review! I've synthesized the existing patch
> > > and review into something that successfully advertises router
> > > preferences in local testing (verified w/ rdisc6). This patch does not
> > > implement the route information option specified in RFC 4191 section
> > > 2.3.
> > >
> > > diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c
> > > index 8178b058629..4031da6b99d 100644
> > > --- a/usr.sbin/rad/frontend.c
> > > +++ b/usr.sbin/rad/frontend.c
> > > @@ -411,7 +411,7 @@ frontend_dispatch_main(int fd, short event, void
> *bula)
> > > ra_prefix_conf))
> > >fatalx("%s: IMSG_RECONF_RA_PREFIX wrong "
> > > "length: %lu", __func__,
> > > -IMSG_DATA_SIZE(imsg));
> > > +IMSG_DATA_SIZE(imsg));
> > >if ((ra_prefix_conf = malloc(sizeof(struct
> > > ra_prefix_conf))) == NULL)
> > >fatal(NULL);
> > > @@ -1023,6 +1023,18 @@ build_packet(struct ra_iface *ra_iface)
> > >ra->nd_ra_router_lifetime =
> > > htons(ra_options_conf->router_lifetime);
> > >}
> > > +
> > > +   /* add router preference flags */
> > > +   if (ra_options_conf->preference == ND_RA_FLAG_RTPREF_RSV) {
> > > +   fatalx("Invalid router preference found during RA packet
> > > construction.");
> > > +   }
> > > +
> > > +   if (ra_options_conf->router_lifetime == 0) {
> > > +   log_debug("Router lifetime set to zero; ignoring router
> > > preference per https://tools.ietf.org/html/rfc4191#section-2.2;);
> > > +   } else {
> > > +   ra->nd_ra_flags_reserved |= ra_options_conf->preference;
> > > +   }
> > > +
> > >ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time);
> > >ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer);
> > >p += sizeof(*ra);
> > > diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y
> > > index 004e5e22f92..74480148246 100644
> > > --- a/usr.sbin/rad/parse.y
> > > +++ b/usr.sbin/rad/parse.y
> > > @@ -32,6 +32,7 @@
> > > #include 
> > > #include 
> > > +#include 
> > > #include 
> > > #include 
> > > @@ -117,10 +118,12 @@ typedef struct {
> > > %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER
> > > %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS
> > > %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU
> > > +%token PREFERENCE LOW MEDIUM HIGH
> > > %token   STRING
> > > %token   NUMBER
> > > %typeyesno
> > > +%typepreference
> > > %typestring
> > 

Re: How do I publish default router preferences using rad?

2019-08-17 Thread Caleb Callaway
If it interests anyone, I've also implemented the route option
described in https://tools.ietf.org/html/rfc4191#section-2.3

I find sharing patches via this mailing list particularly unwieldy,
so I've pushed my work to a git branch at
https://github.com/cqcallaw/src/tree/rfc-4191

On Wed, Aug 7, 2019 at 11:27 PM Caleb  wrote:
>
> Thank you for the code and review! I've synthesized the existing patch
> and review into something that successfully advertises router
> preferences in local testing (verified w/ rdisc6). This patch does not
> implement the route information option specified in RFC 4191 section
> 2.3.
>
> diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c
> index 8178b058629..4031da6b99d 100644
> --- a/usr.sbin/rad/frontend.c
> +++ b/usr.sbin/rad/frontend.c
> @@ -411,7 +411,7 @@ frontend_dispatch_main(int fd, short event, void *bula)
> ra_prefix_conf))
>fatalx("%s: IMSG_RECONF_RA_PREFIX wrong "
> "length: %lu", __func__,
> -IMSG_DATA_SIZE(imsg));
> +IMSG_DATA_SIZE(imsg));
>if ((ra_prefix_conf = malloc(sizeof(struct
> ra_prefix_conf))) == NULL)
>fatal(NULL);
> @@ -1023,6 +1023,18 @@ build_packet(struct ra_iface *ra_iface)
>ra->nd_ra_router_lifetime =
> htons(ra_options_conf->router_lifetime);
>}
> +
> +   /* add router preference flags */
> +   if (ra_options_conf->preference == ND_RA_FLAG_RTPREF_RSV) {
> +   fatalx("Invalid router preference found during RA packet
> construction.");
> +   }
> +
> +   if (ra_options_conf->router_lifetime == 0) {
> +   log_debug("Router lifetime set to zero; ignoring router
> preference per https://tools.ietf.org/html/rfc4191#section-2.2;);
> +   } else {
> +   ra->nd_ra_flags_reserved |= ra_options_conf->preference;
> +   }
> +
>ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time);
>ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer);
>p += sizeof(*ra);
> diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y
> index 004e5e22f92..74480148246 100644
> --- a/usr.sbin/rad/parse.y
> +++ b/usr.sbin/rad/parse.y
> @@ -32,6 +32,7 @@
> #include 
> #include 
> +#include 
> #include 
> #include 
> @@ -117,10 +118,12 @@ typedef struct {
> %token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER
> %token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS
> %token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU
> +%token PREFERENCE LOW MEDIUM HIGH
> %token   STRING
> %token   NUMBER
> %typeyesno
> +%typepreference
> %typestring
> %%
> @@ -166,6 +169,11 @@ yesno  : YES   { $$ = 1; }
>| NO{ $$ = 0; }
>;
> +preference : LOW   { $$ = ND_RA_FLAG_RTPREF_LOW; }
> +   | MEDIUM { $$ = ND_RA_FLAG_RTPREF_MEDIUM; }
> +   | HIGH { $$ = ND_RA_FLAG_RTPREF_HIGH; }
> +   ;
> +
> varset : STRING '=' string {
>char *s = $1;
>if (cmd_opts & OPT_VERBOSE)
> @@ -213,6 +221,9 @@ ra_opt_block: DEFAULT ROUTER yesno {
>| MTU NUMBER {
>ra_options->mtu = $2;
>}
> +   | PREFERENCE preference {
> +   ra_options->preference = $2;
> +   }
>| DNS dns_block
>;
> @@ -426,16 +437,20 @@ lookup(char *s)
>{"default", DEFAULT},
>{"dns", DNS},
>{"hop", HOP},
> +   {"high",HIGH},
>{"include", INCLUDE},
>{"interface",   RA_IFACE},
>{"lifetime",LIFETIME},
>{"limit",   LIMIT},
> +   {"low", LOW},
>{"managed", MANAGED},
> +   {"medium",  MEDIUM},
>{"mtu", MTU},
>{"nameserver",  NAMESERVER},
>{"no",  NO},
>{"on-link", ONLINK},
>{"other",   OTHER},
> +   {"preference",  PREFERENCE},
>{"preferred",   PREFERRED},
>{"prefix",  PREFIX},
>{"reachable",   REACHABLE},
> diff --git a/usr.sbin/rad/printconf.c b/usr.sbin/rad/printconf.c
> index d42890da518..c2173d2142f 100644
> --- a/usr.sbin/rad/printconf.c
> +++ b/usr.sbin/rad/printconf.c
> @@ -26,6 +26,7 @@
> #include 
> #include 
> +#include 
> #include 
> #include 
> @@ -34,6 +35,7 @@
> #include "rad.h"
> const char*yesno(int);
> +const char*preference(int);

Re: How do I publish default router preferences using rad?

2019-08-08 Thread Caleb
u %u\n", indent, ra_options->mtu);
+   if (ra_options->preference != ND_RA_FLAG_RTPREF_RSV)
+   printf("%spreference %s\n", indent,
+preference(ra_options->preference));
   if (!SIMPLEQ_EMPTY(_options->ra_rdnss_list) ||
!SIMPLEQ_EMPTY(_options->ra_dnssl_list)) {
diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c
index 93675167b6b..cb0593f11ab 100644
--- a/usr.sbin/rad/rad.c
+++ b/usr.sbin/rad/rad.c
@@ -433,7 +433,7 @@ main_dispatch_frontend(int fd, short event, void *bula)
   case IMSG_CTL_LOG_VERBOSE:
   if (IMSG_DATA_SIZE(imsg) != sizeof(verbose))
   fatalx("%s: IMSG_CTL_LOG_VERBOSE wrong length: "
-"%lu", __func__, IMSG_DATA_SIZE(imsg));
+"%lu", __func__, IMSG_DATA_SIZE(imsg));
   memcpy(, imsg.data, sizeof(verbose));
   log_setverbose(verbose);
   break;
@@ -754,6 +754,7 @@ config_new_empty(void)
   xconf->ra_options.cur_hl = 0;
   xconf->ra_options.m_flag = 0;
   xconf->ra_options.o_flag = 0;
+   xconf->ra_options.preference = ND_RA_FLAG_RTPREF_MEDIUM;
   xconf->ra_options.router_lifetime = 1800;
   xconf->ra_options.reachable_time = 0;
   xconf->ra_options.retrans_timer = 0;
diff --git a/usr.sbin/rad/rad.conf.5 b/usr.sbin/rad/rad.conf.5
index f651a715d1a..b822f3d195d 100644
--- a/usr.sbin/rad/rad.conf.5
+++ b/usr.sbin/rad/rad.conf.5
@@ -107,6 +107,8 @@ The default is 1800 seconds.
.\" XXX
.\" .It Ic retrans timer Ar number
.\" XXX
+.It Ic preference Pq Ic low Ns | Ns Ic medium Ns | Ns Ic high
+Communicate router preference to clients. The default is medium.
.El
.Sh INTERFACES
A list of interfaces or interface groups to send advertisments on:
diff --git a/usr.sbin/rad/rad.h b/usr.sbin/rad/rad.h
index 2bbf7c8ed5c..cfaa5e88638 100644
--- a/usr.sbin/rad/rad.h
+++ b/usr.sbin/rad/rad.h
@@ -92,6 +92,7 @@ struct ra_options_conf {
   int cur_hl;     /* current hop limit */
   int m_flag; /* managed address conf flag */
   int o_flag; /* other conf flag */
+   int preference; /* router preference (see RFC 4191 2.2) */
   int router_lifetime;/* default router lifetime */
   uint32_treachable_time;
   uint32_tretrans_timer;


On Wed, Aug 7, 2019 at 2:04 AM Florian Obser  wrote:
>
> On Tue, Aug 06, 2019 at 11:17:04PM +0200, Sebastian Benoit wrote:
> > Caleb(enlightened.des...@gmail.com) on 2019.08.06 08:05:48 -0700:
> > > How do I publish default router preferences as defined in RFC 4191
> > > (https://tools.ietf.org/html/rfc4191) using rad in OpenBSD 6.5?
> > > I've read the friendly rad.conf man page
> > > (https://man.openbsd.org/rad.conf.5) and scanned the source
> > > (https://github.com/openbsd/src/tree/master/usr.sbin/rad) with no
> > > success.
> >
> > You can't, because it was not implemented.
> >
> > That is, until now.
> >
> > I wrote a patch, which you can test if you like. It's completly untested
> > though.
> >
>
> needs more yak shaving
>
> >
> > diff --git usr.sbin/rad/frontend.c usr.sbin/rad/frontend.c
> > index 8178b058629..75723797fcf 100644
> > --- usr.sbin/rad/frontend.c
> > +++ usr.sbin/rad/frontend.c
> > @@ -1016,6 +1016,8 @@ build_packet(struct ra_iface *ra_iface)
> >   ra->nd_ra_flags_reserved |= ND_RA_FLAG_MANAGED;
> >   if (ra_options_conf->o_flag)
> >   ra->nd_ra_flags_reserved |= ND_RA_FLAG_OTHER;
> > + ra->nd_ra_flags_reserved |=
> > + ra_options_conf->preference;
> >   if (ra_iface->removed)
> >   /* tell clients that we are no longer a default router */
> >   ra->nd_ra_router_lifetime = 0;
> > @@ -1048,6 +1050,8 @@ build_packet(struct ra_iface *ra_iface)
> >   if (ra_prefix_conf->aflag)
> >   ndopt_pi->nd_opt_pi_flags_reserved |=
> >   ND_OPT_PI_FLAG_AUTO;
> > + ndopt_pi->nd_opt_pi_flags_reserved |=
> > + ra_prefix_conf->preference;
>
> This is a prefix information option (type 3) not a route information option 
> (type 24).
> Option 3 does not have a preference.
>
> >   ndopt_pi->nd_opt_pi_valid_time = 
> > htonl(ra_prefix_conf->vltime);
> >   ndopt_pi->nd_opt_pi_preferred_time =
> >   htonl(ra_prefix_conf->pltime);
> > diff --git usr.sbin/rad/parse.y usr.sbin/rad/parse.y
> > index 004e5e22f92..b004ab37356 100644
> > --- usr.sbin/rad/parse.y
> > +++ usr.sbin/rad/parse.y
> > @@ -106,6 +106,7 @@ typedef struct {
> >   union {
> >   int64_t  number;
> >   

How do I publish default router preferences using rad?

2019-08-06 Thread Caleb
How do I publish default router preferences as defined in RFC 4191
(https://tools.ietf.org/html/rfc4191) using rad in OpenBSD 6.5?
I've read the friendly rad.conf man page
(https://man.openbsd.org/rad.conf.5) and scanned the source
(https://github.com/openbsd/src/tree/master/usr.sbin/rad) with no
success.

Thanks,
-Caleb



Re: Wireless Stack improvements and hacking

2019-03-03 Thread Caleb Squires
> Theo,
>>>
>>> Thank you so much for the wireless stack improvements in OpenBSD 6.5.
>>>
>>> I would though like you to focus on Radio Frequency attacks rather than
>>> just code.
>>>
>> I'm not asking you to become an RF   Engineer lol
>>
>>> Everything we use to communicate starts off generating RF signals
>>> whether it be your telephone, cell phone, radio, Bluetooth, speakers, etc.
>>> Without RF the world be alot safer lol.
>>>
>>> Now the question is can I change the frequency wave patterns to
>>> establish different downlink and uplink data streams to benefit what ever I
>>> want to do ? To hack..
>>>
>>> Unfortunately yes, formula for error free data calculations over radio
>>> waves with ( noise factored in)...
>>>
>>> Look at the following:
>>>
>>> To calculate this you can use the Shannon–Hartley theorem
>>> <https://en.wikipedia.org/wiki/Shannon%E2%80%93Hartley_theorem>.
>>>
>>> C=Blog2(1+SN)C=Blog2⁡(1+SN)
>>>
>>> where
>>>
>>> C is the channel capacity in bits per second;
>>> B is the bandwidth of the channel in hertz (passband bandwidth in case
>>> of a modulated signal);
>>> S is the average received signal power over the bandwidth (in case of a
>>> modulated signal, often denoted C, i.e. modulated carrier), measured in
>>> watts (or volts squared);
>>> N is the average noise or interference power over the bandwidth,
>>> measured in watts (or volts squared);
>>> and S/N is the signal-to-noise ratio (SNR) or the carrier-to-noise ratio
>>> (CNR) of the communication signal to the Gaussian noise interference
>>> expressed as a linear power ratio (not as logarithmic decibels)
>>>
>>> I'm sure your genius mind will think of something...
>>>
>>> Cheers,
>>>
>>> Caleb Squires - VE3UPK
>>> RF Engineer
>>>
>>