diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 16:33:33 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-05-23 16:33:33 +0000 |
commit | 9e0636e7e7be4ffcb6f696d956772333828f27dd (patch) | |
tree | 734cf69424deb58bb56651b4ee7828075ddb1852 | |
parent | e34b75e68e25f6ea1db06c2e244a17c644b4688e (diff) |
Minor adjustments in l2vpn code.
* Define a new constant for the default pseudowire type;
* On l2vpn_new(), initialize the l2vpn lists with LIST_NEW (cosmetic
because the struct was calloc'ed);
* Add a const qualifier to the second parameter of l2vpn_find();
* Remove l2vpn_if_del() and use just free() instead.
-rw-r--r-- | usr.sbin/ldpd/l2vpn.c | 17 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.h | 5 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldp.h | 3 |
3 files changed, 11 insertions, 14 deletions
diff --git a/usr.sbin/ldpd/l2vpn.c b/usr.sbin/ldpd/l2vpn.c index 291812dc79b..7396e953199 100644 --- a/usr.sbin/ldpd/l2vpn.c +++ b/usr.sbin/ldpd/l2vpn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2vpn.c,v 1.4 2016/05/23 16:20:59 renato Exp $ */ +/* $OpenBSD: l2vpn.c,v 1.5 2016/05/23 16:33:32 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -52,13 +52,16 @@ l2vpn_new(const char *name) /* set default values */ l2vpn->mtu = DEFAULT_L2VPN_MTU; - l2vpn->pw_type = PW_TYPE_ETHERNET; + l2vpn->pw_type = DEFAULT_PW_TYPE; + + LIST_INIT(&l2vpn->if_list); + LIST_INIT(&l2vpn->pw_list); return (l2vpn); } struct l2vpn * -l2vpn_find(struct ldpd_conf *xconf, char *name) +l2vpn_find(struct ldpd_conf *xconf, const char *name) { struct l2vpn *l2vpn; @@ -77,7 +80,7 @@ l2vpn_del(struct l2vpn *l2vpn) while ((lif = LIST_FIRST(&l2vpn->if_list)) != NULL) { LIST_REMOVE(lif, entry); - l2vpn_if_del(lif); + free(lif); } while ((pw = LIST_FIRST(&l2vpn->pw_list)) != NULL) { LIST_REMOVE(pw, entry); @@ -125,12 +128,6 @@ l2vpn_if_find(struct l2vpn *l2vpn, unsigned int ifindex) return (NULL); } -void -l2vpn_if_del(struct l2vpn_if *lif) -{ - free(lif); -} - struct l2vpn_pw * l2vpn_pw_new(struct l2vpn *l2vpn, struct kif *kif) { diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h index d43eec303cd..36dbbf040ab 100644 --- a/usr.sbin/ldpd/lde.h +++ b/usr.sbin/ldpd/lde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.h,v 1.30 2016/05/23 16:14:36 renato Exp $ */ +/* $OpenBSD: lde.h,v 1.31 2016/05/23 16:33:32 renato Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -161,12 +161,11 @@ void lde_label_list_free(struct lde_nbr *); /* l2vpn.c */ struct l2vpn *l2vpn_new(const char *); -struct l2vpn *l2vpn_find(struct ldpd_conf *, char *); +struct l2vpn *l2vpn_find(struct ldpd_conf *, const char *); void l2vpn_del(struct l2vpn *); void l2vpn_init(struct l2vpn *); struct l2vpn_if *l2vpn_if_new(struct l2vpn *, struct kif *); struct l2vpn_if *l2vpn_if_find(struct l2vpn *, unsigned int); -void l2vpn_if_del(struct l2vpn_if *l); struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, struct kif *); struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, unsigned int); void l2vpn_pw_del(struct l2vpn_pw *); diff --git a/usr.sbin/ldpd/ldp.h b/usr.sbin/ldpd/ldp.h index f3f1cda854e..e72b8fa31eb 100644 --- a/usr.sbin/ldpd/ldp.h +++ b/usr.sbin/ldpd/ldp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldp.h,v 1.24 2016/05/23 16:12:28 renato Exp $ */ +/* $OpenBSD: ldp.h,v 1.25 2016/05/23 16:33:32 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -229,6 +229,7 @@ struct address_list_tlv { #define CONTROL_WORD_FLAG 0x8000 #define PW_TYPE_ETHERNET_TAGGED 0x0004 #define PW_TYPE_ETHERNET 0x0005 +#define DEFAULT_PW_TYPE PW_TYPE_ETHERNET /* RFC 4447 Sub-TLV record */ struct subtlv { |