Skip to content

Add AdvSNACRouterFlag option to set the SNAC router bit #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2025/05/19 Add AdvSNACRouterFlag <Kimmo Kulovesi>

2024/12/31 Release v2.20
build: annotated/signed tags need a tweak to verify correctly
build: need awk for newer autoconf
Expand Down
5 changes: 5 additions & 0 deletions defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
#define DFLT_AdvIntervalOpt 0
#define DFLT_AdvHomeAgentInfo 0

#define DFLT_AdvSNACRouterFlag 0

/* Option types (defined also at least in glibc 2.2's netinet/icmp6.h) */

#ifndef ND_OPT_RTR_ADV_INTERVAL
Expand Down Expand Up @@ -242,6 +244,9 @@ struct nd_opt_dnssl_info_local {
#define ND_OPT_RDNSSI_FLAG_S 0x0008
#endif
#endif
#ifndef ND_RA_FLAG_SNAC_ROUTER
#define ND_RA_FLAG_SNAC_ROUTER 0x02
#endif

/* Captive Portal RFC 8910 */

Expand Down
5 changes: 5 additions & 0 deletions gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ int yylex_destroy (void);
%token T_AdvHomeAgentFlag
%token T_AdvIntervalOpt
%token T_AdvHomeAgentInfo
%token T_AdvSNACRouterFlag

%token T_Base6Interface
%token T_Base6to4Interface
Expand Down Expand Up @@ -349,6 +350,10 @@ ifaceval : T_MinRtrAdvInterval NUMBER ';'
{
iface->mipv6.HomeAgentLifetime = $2;
}
| T_AdvSNACRouterFlag SWITCH ';'
{
iface->ra_header_info.AdvSNACRouterFlag = $2;
}
| T_UnicastOnly SWITCH ';'
{
iface->UnicastOnly = $2;
Expand Down
1 change: 1 addition & 0 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void iface_init_defaults(struct Interface *iface)
iface->ra_header_info.AdvRetransTimer = DFLT_AdvRetransTimer;
iface->ra_header_info.AdvCurHopLimit = DFLT_AdvCurHopLimit;
iface->ra_header_info.AdvHomeAgentFlag = DFLT_AdvHomeAgentFlag;
iface->ra_header_info.AdvSNACRouterFlag = DFLT_AdvSNACRouterFlag;

iface->mipv6.AdvIntervalOpt = DFLT_AdvIntervalOpt;
iface->mipv6.AdvHomeAgentInfo = DFLT_AdvHomeAgentInfo;
Expand Down
8 changes: 8 additions & 0 deletions radvd.conf.5.man
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ Note: RFC4861's suggested default value is significantly longer: 7 days.

Default: 14400 seconds (4 hours)

.TP
.BR AdvSNACRouterFlag " " on | off

When set, indicates the router is a SNAC router (stub network auto
configuration, e.g., for IPv6-only stub networks).
Comment on lines +534 to +535
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please link to the RFC here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is an official RFC yet, even though the bit has been assigned (ietf-wg-snac/draft-ietf-snac-simple#54)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Default: off

.TP
.BR DeprecatePrefix " " on | off

Expand Down
1 change: 1 addition & 0 deletions radvd.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct Interface {
int AdvOtherConfigFlag;
uint8_t AdvCurHopLimit;
int AdvHomeAgentFlag;
int AdvSNACRouterFlag;
int32_t AdvDefaultLifetime; /* XXX: really uint16_t but we need to use -1 */
int AdvDefaultPreference;
uint32_t AdvReachableTime;
Expand Down
3 changes: 3 additions & 0 deletions radvdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ static void print_ff(unsigned char *msg, int len, struct sockaddr_in6 *addr, int
if (!edefs || DFLT_AdvHomeAgentFlag != (ND_RA_FLAG_HOME_AGENT == (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT)))
printf("\tAdvHomeAgentFlag %s;\n", (radvert->nd_ra_flags_reserved & ND_RA_FLAG_HOME_AGENT) ? "on" : "off");

if (!edefs || DFLT_AdvHomeAgentFlag != (ND_RA_FLAG_SNAC_ROUTER == (radvert->nd_ra_flags_reserved & ND_RA_FLAG_SNAC_ROUTER)))
printf("\tAdvSNACRouterFlag %s;\n", (radvert->nd_ra_flags_reserved & ND_RA_FLAG_SNAC_ROUTER) ? "on" : "off");

/* Route Preferences and more specific routes */
/* XXX two middlemost bits from 8 bit field */
if (!edefs || (((radvert->nd_ra_flags_reserved & 0x18) >> 3) & 0xff) != DFLT_AdvDefaultPreference) {
Expand Down
1 change: 1 addition & 0 deletions scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ UnicastOnly { return T_UnicastOnly; }
UnrestrictedUnicast { return T_UnrestrictedUnicast; }
AdvRASolicitedUnicast { return T_AdvRASolicitedUnicast; }
AdvCaptivePortalAPI { return T_AdvCaptivePortalAPI; }
AdvSNACRouterFlag { return T_AdvSNACRouterFlag; }

Base6Interface { return T_Base6Interface; }
Base6to4Interface { return T_Base6to4Interface; }
Expand Down
1 change: 1 addition & 0 deletions send.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ static void add_ra_header(struct safe_buffer *sb, struct ra_header_info const *r
radvert.nd_ra_flags_reserved |= (ra_header_info->AdvOtherConfigFlag) ? ND_RA_FLAG_OTHER : 0;
/* Mobile IPv6 ext */
radvert.nd_ra_flags_reserved |= (ra_header_info->AdvHomeAgentFlag) ? ND_RA_FLAG_HOME_AGENT : 0;
radvert.nd_ra_flags_reserved |= (ra_header_info->AdvSNACRouterFlag) ? ND_RA_FLAG_SNAC_ROUTER : 0;

radvert.nd_ra_router_lifetime = cease_adv ? 0 : htons(ra_header_info->AdvDefaultLifetime);
radvert.nd_ra_flags_reserved |= (ra_header_info->AdvDefaultPreference << ND_OPT_RI_PRF_SHIFT) & ND_OPT_RI_PRF_MASK;
Expand Down