Skip to contentSkip to conversation

Add support for IPv6 RADIUS attributes

PATCH Alarig Le Lay 5 participants 8 messages Jan 8, 2016 – Mar 8, 2016 PPP protocol drivers and compressors

lore
Share & tools
lore
#0 lore raw

Hi,

This patch aims to handle IPv6 RADIUS attributes. The current ppp does not handle them and raise an error that looks like 'rc_read_dictionary:
invalid type on line 89 of dictionary /etc/radiusclient/dictionary'. I use those attributes to put it into the radvd conf from /run/vpn/radvd-user.${PPP_IFACE}.conf.

From 5c0cac0eeecc32e5023d353a8420633827800e8e Mon Sep 17 00:00:00 2001
From: Benjamin Cama <[email protected]>
Date: Sun, 11 Oct 2015 18:08:11 +0200
Subject: [PATCH] Handle IPv6 RADIUS attributes

---
 pppd/plugins/radius/avpair.c       | 26 +++++++++++++++++++++++++-
 pppd/plugins/radius/dict.c         | 12 ++++++++++++
 pppd/plugins/radius/radiusclient.h | 11 +++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
pppd/plugins/radius/avpair.c +3 -0
index 716d23f..7536941 100644
@@ -222,6 +222,9 @@ VALUE_PAIR *rc_avpair_gen (AUTH_HDR *auth)
 			{
 
 			    case PW_TYPE_STRING:
+			    case PW_TYPE_IFID:
+			    case PW_TYPE_IPV6ADDR:
+			    case PW_TYPE_IPV6PREFIX:
 				memcpy (pair->strvalue, (char *) ptr,

(size_t) attrlen);
pair->strvalue[attrlen] = '\0'; pair->lvalue = attrlen;
@@ -692,9 +695,10 @@ int rc_avpair_parse (char *buffer, VALUE_PAIR **first_pair)
int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value,
int lv)
{
DICT_VALUE *dval;
- char buffer[32];
+ char buffer[INET6_ADDRSTRLEN + 4]; // for a prefix:
addr + '/' + prefixlen
struct in_addr inad;
unsigned char *ptr;
+ char *str;

*name = *value = '\0';

@@ -753,6 +757,26 @@ int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
strncpy(value, buffer, lv-1);
break;

+ case PW_TYPE_IFID:
+ ptr = pair->strvalue;
+ snprintf(buffer, sizeof (buffer), "%x:%x:%x:%x",
+ (ptr[0] << 8) + ptr[1], (ptr[2] << 8) + ptr[3],
+ (ptr[4] << 8) + ptr[5], (ptr[6] << 8) +
ptr[7]);
+ strncpy(value, buffer, lv-1);
+ break;
+
+ case PW_TYPE_IPV6ADDR:
+ inet_ntop(AF_INET6, pair->strvalue, buffer, sizeof
(buffer));
+ strncpy(value, buffer, lv-1);
+ break;
+
+ case PW_TYPE_IPV6PREFIX:
+ inet_ntop(AF_INET6, pair->strvalue + 2, buffer, sizeof
(buffer));
+ str = buffer + strlen(buffer);
+ snprintf(str, sizeof (buffer) - (str - buffer), "/%d",
*(pair->strvalue + 1));
+ strncpy(value, buffer, lv-1);
+ break;
+
default:
error("rc_avpair_tostr: unknown attribute type %d",
pair->type);
return (-1);

pppd/plugins/radius/dict.c +12 -0
index 72b3e70..3b2add2 100644
@@ -158,6 +158,18 @@ int rc_read_dictionary (char *filename)
 			{
 				type = PW_TYPE_DATE;
 			}
+			else if (strcmp (typestr, "ifid") == 0)
+			{
+				type = PW_TYPE_IFID;
+			}
+			else if (strcmp (typestr, "ipv6addr") == 0)
+			{
+				type = PW_TYPE_IPV6ADDR;
+			}
+			else if (strcmp (typestr, "ipv6prefix") == 0)
+			{
+				type = PW_TYPE_IPV6PREFIX;
+			}
 			else
 			{
 				error("rc_read_dictionary: invalid type

on line %d of dictionary %s",

(quoted diff) +0 -0

b/pppd/plugins/radius/radiusclient.h
index 51b959a..ab4ef2d 100644

pppd/plugins/radius/radiusclient.h +11 -0
@@ -77,6 +77,17 @@ typedef struct pw_auth_hdr
 #define PW_TYPE_INTEGER			1
 #define PW_TYPE_IPADDR			2
 #define PW_TYPE_DATE			3
+#define PW_TYPE_ABINARY			4
+#define PW_TYPE_OCTETS			5
+#define PW_TYPE_IFID			6
+#define PW_TYPE_IPV6ADDR		7
+#define PW_TYPE_IPV6PREFIX		8
+#define PW_TYPE_BYTE			9
+#define PW_TYPE_SHORT			10
+#define PW_TYPE_ETHERNET	       	11
+#define PW_TYPE_SIGNED			12
+#define PW_TYPE_COMBO_IP	       	13
+#define PW_TYPE_TLV	       		14
 
 /* standard RADIUS codes */
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 4 lines · Alarig Le Lay

Hi,

This patch aims to handle IPv6 RADIUS attributes. The current ppp does not handle them and raise an error that looks like 'rc_read_dictionary:

The error() is a design flaw. The radius plugin for ppp should just ignore (or at most warn about) attributes which it doesn't care about.

Quoted 128 lines

invalid type on line 89 of dictionary /etc/radiusclient/dictionary'.

I use those attributes to put it into the radvd conf from /run/vpn/radvd-user.${PPP_IFACE}.conf.

From 5c0cac0eeecc32e5023d353a8420633827800e8e Mon Sep 17 00:00:00 2001
From: Benjamin Cama <[email protected]>
Date: Sun, 11 Oct 2015 18:08:11 +0200
Subject: [PATCH] Handle IPv6 RADIUS attributes

---
 pppd/plugins/radius/avpair.c       | 26 +++++++++++++++++++++++++-
 pppd/plugins/radius/dict.c         | 12 ++++++++++++
 pppd/plugins/radius/radiusclient.h | 11 +++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)
pppd/plugins/radius/avpair.c +3 -0
index 716d23f..7536941 100644
@@ -222,6 +222,9 @@ VALUE_PAIR *rc_avpair_gen (AUTH_HDR *auth)
 			{
 
 			    case PW_TYPE_STRING:
+			    case PW_TYPE_IFID:
+			    case PW_TYPE_IPV6ADDR:
+			    case PW_TYPE_IPV6PREFIX:
 				memcpy (pair->strvalue, (char *) ptr,
 (size_t) attrlen);
 				pair->strvalue[attrlen] = '\0';
pppd/plugins/radius/avpair.c +1 -1
 				pair->lvalue = attrlen;
@@ -692,9 +695,10 @@ int rc_avpair_parse (char *buffer, VALUE_PAIR
 **first_pair)
 int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value,
 int lv)
 {
 	DICT_VALUE     *dval;
-	char            buffer[32];
+	char            buffer[INET6_ADDRSTRLEN + 4]; // for a prefix:

addr + '/' + prefixlen

pppd/plugins/radius/avpair.c +16 -0
 	struct in_addr  inad;
 	unsigned char         *ptr;
+	char		*str;
 
 	*name = *value = '\0';
@@ -753,6 +757,26 @@ int rc_avpair_tostr (VALUE_PAIR *pair, char *name,
 int ln, char *value, int lv)
 		strncpy(value, buffer, lv-1);
 		break;
 
+	    case PW_TYPE_IFID:
+		ptr = pair->strvalue;
+		snprintf(buffer, sizeof (buffer), "%x:%x:%x:%x",
+			 (ptr[0] << 8) + ptr[1], (ptr[2] << 8) + ptr[3],
+			 (ptr[4] << 8) + ptr[5], (ptr[6] << 8) +
 ptr[7]);
+		strncpy(value, buffer, lv-1);
+		break;
+
+	    case PW_TYPE_IPV6ADDR:
+		inet_ntop(AF_INET6, pair->strvalue, buffer, sizeof
 (buffer));
+		strncpy(value, buffer, lv-1);
+		break;
+
+	    case PW_TYPE_IPV6PREFIX:
+		inet_ntop(AF_INET6, pair->strvalue + 2, buffer, sizeof

(buffer));

pppd/plugins/radius/avpair.c +2 -0
+		str = buffer + strlen(buffer);
+		snprintf(str, sizeof (buffer) - (str - buffer), "/%d",

*(pair->strvalue + 1));

pppd/plugins/radius/avpair.c +3 -0
+		strncpy(value, buffer, lv-1);
+		break;
+
 	    default:
 		error("rc_avpair_tostr: unknown attribute type %d",

pair->type);

pppd/plugins/radius/avpair.c +0 -0
 		return (-1);
pppd/plugins/radius/dict.c +12 -0
index 72b3e70..3b2add2 100644
@@ -158,6 +158,18 @@ int rc_read_dictionary (char *filename)
 			{
 				type = PW_TYPE_DATE;
 			}
+			else if (strcmp (typestr, "ifid") = 0)
+			{
+				type = PW_TYPE_IFID;
+			}
+			else if (strcmp (typestr, "ipv6addr") = 0)
+			{
+				type = PW_TYPE_IPV6ADDR;
+			}
+			else if (strcmp (typestr, "ipv6prefix") = 0)
+			{
+				type = PW_TYPE_IPV6PREFIX;
+			}
 			else
 			{
 				error("rc_read_dictionary: invalid type

on line %d of dictionary %s",

pppd/plugins/radius/radiusclient.h +11 -0
index 51b959a..ab4ef2d 100644
@@ -77,6 +77,17 @@ typedef struct pw_auth_hdr
 #define PW_TYPE_INTEGER			1
 #define PW_TYPE_IPADDR			2
 #define PW_TYPE_DATE			3
+#define PW_TYPE_ABINARY			4
+#define PW_TYPE_OCTETS			5
+#define PW_TYPE_IFID			6
+#define PW_TYPE_IPV6ADDR		7
+#define PW_TYPE_IPV6PREFIX		8
+#define PW_TYPE_BYTE			9
+#define PW_TYPE_SHORT			10
+#define PW_TYPE_ETHERNET	       	11
+#define PW_TYPE_SIGNED			12
+#define PW_TYPE_COMBO_IP	       	13
+#define PW_TYPE_TLV	       		14
 
 /* standard RADIUS codes */
 
#2 lore raw
In reply to Alarig Le Lay

I also have patches to the radius module to use the latest (and maintained) radcli client library at: https://github.com/nmav/radcli

What is your application? As I read your patches, they just make ppp ignore the attributes. Do you intend to do more with the data?

I have patches on both radcli and pppd sides, which haven't all settled yet, so I haven't pushed them anywhere yet.

I'm not sure what the ultimate point of your patches are though. Non-LL IPv6 addresses are not assigned through IP6CP, but rather through RA
and/or DHCPv6. I have a daemon, called rfc6204d, which does this at scale,
but it is not yet sufficiently field tested to release.

--

]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        | network architect  [
]     [email protected]  http://www.sandelman.ca/        |   ruby on rails    [
#3 lore raw
In reply to Alarig Le Lay
Quoted 5 lines · Michael Richardson

I also have patches to the radius module to use the latest (and maintained) radcli client library at: https://github.com/nmav/radcli

What is your application? As I read your patches, they just make ppp ignore the attributes. Do you intend to do more with the data?

On the face of it, the reason for Alarig's patch is to prevent pppd calling 'error()' in response to unknown attributes. As I've already pointed out, there is a much simpler patch to achieve that end.

The radius plugin of pppd shouldn't be trying to validate radius config files; it should just read the data it needs from the file. If it finds other stuff, it can just ignore it.

Quoted 15 lines

I have patches on both radcli and pppd sides, which haven't all settled yet, so I haven't pushed them anywhere yet.

I'm not sure what the ultimate point of your patches are though. Non-LL IPv6 addresses are not assigned through IP6CP, but rather through RA
and/or DHCPv6. I have a daemon, called rfc6204d, which does this at scale,
but it is not yet sufficiently field tested to release.

--

]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        | network architect  [
]     [email protected]  http://www.sandelman.ca/        |   ruby on rails    [
#5 lore raw
In reply to Alarig Le Lay

Hi

I think it should validate against the dictionary then only use the parameters it needs.

This seems to be the standard I've see in other software.

Mike

Quoted 37 lines · Charlie Brady
Quoted 10 lines · Michael Richardson

I also have patches to the radius module to use the latest (and maintained) radcli client library at: https://github.com/nmav/radcli

What is your application? As I read your patches, they just make ppp ignore the attributes. Do you intend to do more with the data?

On the face of it, the reason for Alarig's patch is to prevent pppd calling 'error()' in response to unknown attributes. As I've already pointed out, there is a much simpler patch to achieve that end.

The radius plugin of pppd shouldn't be trying to validate radius config files; it should just read the data it needs from the file. If it finds other stuff, it can just ignore it.

Quoted 9 lines

I have patches on both radcli and pppd sides, which haven't all settled yet, so I haven't pushed them anywhere yet.

I'm not sure what the ultimate point of your patches are though. Non-LL IPv6 addresses are not assigned through IP6CP, but rather through RA
and/or DHCPv6. I have a daemon, called rfc6204d, which does this at scale,
but it is not yet sufficiently field tested to release.

Quoted 4 lines

--

]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        | network architect  [
]     [email protected]  http://www.sandelman.ca/        |   ruby on rails    [

--
To unsubscribe from this list: send the line "unsubscribe linux-ppp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Alarig Le Lay
Quoted 2 lines · Michael Richardson

What is your application? As I read your patches, they just make ppp ignore the attributes. Do you intend to do more with the data?

I added the attributes to the radclient dictionary.
The attributes go to /run/radattr.$PPP_IFACE; and from this I parse them to inject it into the radvd conf.
Without the patch, ppp complains about unknown attributes in the dict.

Signature · 1 line
Alarig Le Lay
#7 lore raw
In reply to Alarig Le Lay

SGksCgpNaWNoYWVsIFJpY2hhcmRzb24gPG1jciA8YXQ+IHNhbmRlbG1hbi5jYT4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