diff options
author | Maria Matejka <mq@ucw.cz> | 2022-05-30 16:48:17 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-05-30 16:48:17 +0200 |
commit | b7e2edd4419fecb09b8690f8731e172f0c24789c (patch) | |
tree | 41c80ab4b0d524ff34e207bf15e8d79191276a2c /proto/babel/babel.c | |
parent | d7bec897ab772cdccce10b296d4efd48d9181297 (diff) | |
parent | 1d309c4ce6e95b68c64a8f007f6dd2f1830a5707 (diff) |
Merge commit '1d309c4ce6e95b68c64a8f007f6dd2f1830a5707' into haugesund
Diffstat (limited to 'proto/babel/babel.c')
-rw-r--r-- | proto/babel/babel.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c index 6df80922..fcd7eafb 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -640,6 +640,18 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) if (r) { + struct { + ea_list l; + eattr a[3]; + } eattrs = { + .l.count = 3, + .a = { + EA_LITERAL_EMBEDDED(EA_BABEL_METRIC, T_INT, 0, r->metric), + EA_LITERAL_STORE_ADATA(EA_BABEL_ROUTER_ID, T_OPAQUE, 0, &r->router_id, sizeof(r->router_id)), + EA_LITERAL_EMBEDDED(EA_BABEL_SEQNO, T_INT, 0, r->seqno), + } + }; + rta a0 = { .source = RTS_BABEL, .scope = SCOPE_UNIVERSE, @@ -648,29 +660,7 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e) .from = r->neigh->addr, .nh.gw = r->next_hop, .nh.iface = r->neigh->ifa->iface, - .eattrs = alloca(sizeof(ea_list) + 3*sizeof(eattr)), - }; - - *a0.eattrs = (ea_list) { .count = 3 }; - a0.eattrs->attrs[0] = (eattr) { - .id = EA_BABEL_METRIC, - .type = T_INT, - .u.data = r->metric, - }; - - struct adata *ad = alloca(sizeof(struct adata) + sizeof(u64)); - ad->length = sizeof(u64); - memcpy(ad->data, &(r->router_id), sizeof(u64)); - a0.eattrs->attrs[1] = (eattr) { - .id = EA_BABEL_ROUTER_ID, - .type = T_OPAQUE, - .u.ptr = ad, - }; - - a0.eattrs->attrs[2] = (eattr) { - .id = EA_BABEL_SEQNO, - .type = T_INT, - .u.data = r->seqno, + .eattrs = &eattrs.l, }; /* |