Re: make art independent of struct sockaddr

2017-01-19 Thread Claudio Jeker
On Fri, Jan 20, 2017 at 01:26:11PM +1000, Martin Pieuchot wrote:
> On 20/01/17(Fri) 03:04, Claudio Jeker wrote:
> > I want to use art routing tables with pf addrs and not sockaddrs.
> > Art itself does not care but the API requires sockaddr pointers in some
> > places. This changes those to void *.
> > 
> > OK? This is step 2 to a new pf_table backend.
> 
> What's the problem with uint8_t?  If possible I'd prefer keeping that
> type since it's clear that we're dealing with bytes.

IIRC I did it to reduce the amount of casts needed. You can pass the
address of a struct in_addr or similar this way without having to cast.
 
> I also think that ``an_dst'' is no longer used and can die.  The value
> attached to an art_node is now ``an_rtlist''.  This might be renamed and
> we could use a "void *" since you're not going to use list for pf.
> 
> That means we could fold ``an_rtlist'' in the union and reduce the size
> of 'struct art_node'.
> 
art_get() still sets it unconditionally. I have nothing against olding
an_rtlist in but think we should make sure that you can use art without
multipath...

-- 
:wq Claudio



Re: make art independent of struct sockaddr

2017-01-19 Thread Martin Pieuchot
On 20/01/17(Fri) 03:04, Claudio Jeker wrote:
> I want to use art routing tables with pf addrs and not sockaddrs.
> Art itself does not care but the API requires sockaddr pointers in some
> places. This changes those to void *.
> 
> OK? This is step 2 to a new pf_table backend.

What's the problem with uint8_t?  If possible I'd prefer keeping that
type since it's clear that we're dealing with bytes.

I also think that ``an_dst'' is no longer used and can die.  The value
attached to an art_node is now ``an_rtlist''.  This might be renamed and
we could use a "void *" since you're not going to use list for pf.

That means we could fold ``an_rtlist'' in the union and reduce the size
of 'struct art_node'.



make art independent of struct sockaddr

2017-01-19 Thread Claudio Jeker
I want to use art routing tables with pf addrs and not sockaddrs.
Art itself does not care but the API requires sockaddr pointers in some
places. This changes those to void *.

OK? This is step 2 to a new pf_table backend.
-- 
:wq Claudio

Index: net/art.c
===
RCS file: /cvs/src/sys/net/art.c,v
retrieving revision 1.24
diff -u -p -r1.24 art.c
--- net/art.c   15 Sep 2016 02:00:18 -  1.24
+++ net/art.c   10 Oct 2016 18:16:36 -
@@ -247,7 +247,7 @@ art_findex(struct art_table *at, uint8_t
  * Return the best existing match for a destination.
  */
 struct art_node *
-art_match(struct art_root *ar, uint8_t *addr, struct srp_ref *nsr)
+art_match(struct art_root *ar, void *addr, struct srp_ref *nsr)
 {
struct srp_ref  dsr, ndsr;
void*entry;
@@ -310,7 +310,7 @@ done:
  * it does not exist.
  */
 struct art_node *
-art_lookup(struct art_root *ar, uint8_t *addr, int plen, struct srp_ref *nsr)
+art_lookup(struct art_root *ar, void *addr, int plen, struct srp_ref *nsr)
 {
void*entry;
struct art_table*at;
@@ -368,7 +368,7 @@ done:
  * same destination/mask pair is already present.
  */
 struct art_node *
-art_insert(struct art_root *ar, struct art_node *an, uint8_t *addr, int plen)
+art_insert(struct art_root *ar, struct art_node *an, void *addr, int plen)
 {
struct art_table*at, *child;
struct art_node *node;
@@ -472,7 +472,7 @@ art_table_insert(struct art_root *ar, st
  * Deletion API function.
  */
 struct art_node *
-art_delete(struct art_root *ar, struct art_node *an, uint8_t *addr, int plen)
+art_delete(struct art_root *ar, struct art_node *an, void *addr, int plen)
 {
struct art_table*at;
struct art_node *node;
@@ -922,7 +922,7 @@ moveup:
 }
 
 struct art_node *
-art_get(struct sockaddr *dst, uint8_t plen)
+art_get(void *dst, uint8_t plen)
 {
struct art_node *an;
 
Index: net/art.h
===
RCS file: /cvs/src/sys/net/art.h,v
retrieving revision 1.15
diff -u -p -r1.15 art.h
--- net/art.h   30 Aug 2016 07:42:57 -  1.15
+++ net/art.h   10 Oct 2016 18:16:36 -
@@ -48,7 +48,7 @@ struct rtentry;
 struct art_node {
SRPL_HEAD(, rtentry) an_rtlist; /* Route related to this node */
union {
-   struct sockaddr *an__dst;   /* Destination address (key) */
+   void*an__dst;   /* Destination address (key) */
struct art_node *an__gc;/* Entry on GC list */
}an_pointer;
uint8_t  an_plen;   /* Prefix length */
@@ -58,17 +58,17 @@ struct art_node {
 
 voidart_init(void);
 struct art_root*art_alloc(unsigned int, unsigned int, unsigned int);
-struct art_node *art_insert(struct art_root *, struct art_node *, uint8_t *,
+struct art_node *art_insert(struct art_root *, struct art_node *, void *,
 int);
-struct art_node *art_delete(struct art_root *, struct art_node *, uint8_t *,
+struct art_node *art_delete(struct art_root *, struct art_node *, void *,
 int);
-struct art_node*art_match(struct art_root *, uint8_t *, struct srp_ref 
*);
-struct art_node *art_lookup(struct art_root *, uint8_t *, int,
+struct art_node*art_match(struct art_root *, void *, struct srp_ref *);
+struct art_node *art_lookup(struct art_root *, void *, int,
 struct srp_ref *);
 int art_walk(struct art_root *,
 int (*)(struct art_node *, void *), void *);
 
-struct art_node*art_get(struct sockaddr *, uint8_t);
+struct art_node*art_get(void *, uint8_t);
 voidart_put(struct art_node *);
 
 #endif /* _NET_ART_H_ */