-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Pseudowire management in Zebra #601
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
#include "openbsd-tree.h" | ||
#include "if.h" | ||
|
||
#define RETRY_SYNC_PW_INTERVAL 5 /* in seconds */ | ||
|
||
enum fec_type { | ||
FEC_TYPE_IPV4, | ||
FEC_TYPE_IPV6, | ||
|
@@ -188,6 +190,7 @@ void fec_snap(struct lde_nbr *); | |
void fec_tree_clear(void); | ||
struct fec_nh *fec_nh_find(struct fec_node *, int, union ldpd_addr *, | ||
ifindex_t, uint8_t); | ||
void update_local_label (struct fec_node *fn, int connected); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused prototype |
||
void lde_kernel_insert(struct fec *, int, union ldpd_addr *, | ||
ifindex_t, uint8_t, int, void *); | ||
void lde_kernel_remove(struct fec *, int, union ldpd_addr *, | ||
|
@@ -235,5 +238,6 @@ void l2vpn_recv_pw_status_wcard(struct lde_nbr *, | |
struct notify_msg *); | ||
void l2vpn_pw_ctl(pid_t); | ||
void l2vpn_binding_ctl(pid_t); | ||
int l2vpn_pw_status_update (struct kpw *kpw); | ||
|
||
#endif /* _LDE_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,17 +153,65 @@ kr_delete(struct kroute *kr) | |
return (zebra_send_mpls_labels(ZEBRA_MPLS_LABELS_DELETE, kr)); | ||
} | ||
|
||
static int | ||
zebra_send_kpw(u_char cmd, struct zclient *zclient, struct kpw *kpw) | ||
{ | ||
struct stream *s; | ||
|
||
debug_zebra_out("ILM %s PW %u (%s) ifindex %hu, type %d. %s -> nexthop %s label %s", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ILM? |
||
(cmd == ZEBRA_KPW_ADD) ? "add" : "delete", | ||
kpw->pwid, kpw->vpn_name, kpw->ifindex, | ||
kpw->pw_type, log_label(kpw->local_label), | ||
log_addr(kpw->af, &kpw->nexthop), log_label(kpw->remote_label)); | ||
|
||
/* Reset stream. */ | ||
s = zclient->obuf; | ||
stream_reset(s); | ||
|
||
zclient_create_header(s, cmd, VRF_DEFAULT); | ||
stream_write (s, kpw->ifname, IF_NAMESIZE); | ||
stream_putw(s, kpw->ifindex); | ||
stream_putl(s, kpw->pw_type); | ||
stream_putl(s, kpw->lsr_id.s_addr); | ||
stream_putl(s, kpw->af); | ||
switch (kpw->af) { | ||
case AF_INET: | ||
stream_put_in_addr(s, &kpw->nexthop.v4); | ||
break; | ||
case AF_INET6: | ||
stream_write (s, (u_char *)&kpw->nexthop.v6, 16); | ||
break; | ||
default: | ||
fatalx("zebra_send_kpw: unknown af"); | ||
} | ||
stream_putl(s, kpw->local_label); | ||
stream_putl(s, kpw->remote_label); | ||
stream_putc(s, kpw->flags); | ||
stream_putl(s, kpw->pwid); | ||
stream_write(s, kpw->vpn_name, L2VPN_NAME_LEN); | ||
stream_putw(s, kpw->ac_port_ifindex); | ||
|
||
/* Put length at the first point of the stream. */ | ||
stream_putw_at(s, 0, stream_get_endp(s)); | ||
|
||
return (zclient_send_message(zclient)); | ||
} | ||
|
||
int | ||
kmpw_set(struct kpw *kpw) | ||
{ | ||
zebra_send_kpw (ZEBRA_KPW_ADD, zclient, kpw); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the TODO comment below. Better yet, rewrite this function like this: |
||
/* TODO */ | ||
|
||
return (0); | ||
} | ||
|
||
int | ||
kmpw_unset(struct kpw *kpw) | ||
{ | ||
zebra_send_kpw (ZEBRA_KPW_DELETE, zclient, kpw); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
/* TODO */ | ||
|
||
return (0); | ||
} | ||
|
||
|
@@ -477,6 +525,46 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, | |
return (0); | ||
} | ||
|
||
/** | ||
* Receive PW status update from Zebra and send it to LDE process. | ||
* | ||
* Params and return type are the ones required by zclient interface. | ||
* | ||
* @param command It will always be ZEBRA_PW_STATUS_UPDATE | ||
* @param zclient To get input stream from | ||
* @param length | ||
* @param vrf_id | ||
* @return 0 on success | ||
*/ | ||
static int | ||
ldp_zebra_read_pw_status_update (int command, struct zclient *zclient, | ||
zebra_size_t length, vrf_id_t vrf_id) | ||
{ | ||
struct stream *s; | ||
uint8_t status; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. padding not consistent with the rest of the code |
||
struct kpw kpw; | ||
|
||
memset (&kpw, 0, sizeof (struct kpw)); | ||
|
||
/* Get input stream. */ | ||
s = zclient->ibuf; | ||
|
||
/* Get data. */ | ||
stream_get (kpw.ifname, s, IF_NAMESIZE); | ||
/* ifindex = stream_getw (s); */ | ||
/* pwid = stream_getl (s); */ | ||
stream_get (kpw.vpn_name, s, L2VPN_NAME_LEN); | ||
status = stream_getc (s); | ||
if (status) | ||
kpw.flags |= F_PW_STATUS_UP; | ||
else | ||
kpw.flags &= ~F_PW_STATUS_UP; | ||
|
||
main_imsg_compose_lde (IMSG_PW_UPDATE, 0, &kpw, sizeof (kpw)); | ||
|
||
return 0; | ||
} | ||
|
||
static void | ||
ldp_zebra_connected(struct zclient *zclient) | ||
{ | ||
|
@@ -507,6 +595,7 @@ ldp_zebra_init(struct thread_master *master) | |
zclient->redistribute_route_ipv4_del = ldp_zebra_read_route; | ||
zclient->redistribute_route_ipv6_add = ldp_zebra_read_route; | ||
zclient->redistribute_route_ipv6_del = ldp_zebra_read_route; | ||
zclient->pw_status_update = ldp_zebra_read_pw_status_update; | ||
} | ||
|
||
void | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,8 @@ enum imsg_type { | |
IMSG_LOG, | ||
IMSG_ACL_CHECK, | ||
IMSG_GET_LABEL_CHUNK, | ||
IMSG_RELEASE_LABEL_CHUNK | ||
IMSG_RELEASE_LABEL_CHUNK, | ||
IMSG_PW_UPDATE | ||
}; | ||
|
||
union ldpd_addr { | ||
|
@@ -531,13 +532,18 @@ struct kroute { | |
}; | ||
|
||
struct kpw { | ||
char ifname[IF_NAMESIZE]; | ||
unsigned short ifindex; | ||
int pw_type; | ||
struct in_addr lsr_id; | ||
int af; | ||
union ldpd_addr nexthop; | ||
uint32_t local_label; | ||
uint32_t remote_label; | ||
uint8_t flags; | ||
uint32_t pwid; | ||
char vpn_name[L2VPN_NAME_LEN]; | ||
unsigned short ac_port_ifindex; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the Also, the other members you're adding here are not necessary in my opinion. We don't want to send protocol-specific pseudowire attributes to zebra, like I think that pseudowires can be uniquely identified by their ifname and ifindex, zebra doesn't need to track more information than that. |
||
|
||
struct kaddr { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,9 @@ typedef enum { | |
ZEBRA_LABEL_MANAGER_CONNECT, | ||
ZEBRA_GET_LABEL_CHUNK, | ||
ZEBRA_RELEASE_LABEL_CHUNK, | ||
ZEBRA_KPW_ADD, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgive the bikeshedding, but I'd prefer to remove the "K" from these constants. ZEBRA_PW_ADD and ZEBRA_PW_DELETE look better. |
||
ZEBRA_KPW_DELETE, | ||
ZEBRA_PW_STATUS_UPDATE, | ||
} zebra_message_types_t; | ||
|
||
struct redist_proto | ||
|
@@ -164,6 +167,7 @@ struct zclient | |
int (*redistribute_route_ipv4_del) (int, struct zclient *, uint16_t, vrf_id_t); | ||
int (*redistribute_route_ipv6_add) (int, struct zclient *, uint16_t, vrf_id_t); | ||
int (*redistribute_route_ipv6_del) (int, struct zclient *, uint16_t, vrf_id_t); | ||
int (*pw_status_update) (int, struct zclient *, uint16_t, vrf_id_t); | ||
}; | ||
|
||
/* Zebra API message flag. */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anywhere