Skip to content

Commit 96c75c8

Browse files
committed
zebra: align nexthop encoding with prior refactor
Signed-off-by: GalaxyGorilla <[email protected]>
1 parent 678424d commit 96c75c8

File tree

2 files changed

+13
-31
lines changed

2 files changed

+13
-31
lines changed

zebra/zebra_rnh.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,7 @@ int send_client(struct rnh *rnh, struct zserv *client, enum rnh_type type,
10641064
for (ALL_NEXTHOPS(re->nhe->nhg, nh))
10651065
if (rnh_nexthop_valid(re, nh)) {
10661066
zapi_nexthop_from_nexthop(&znh, nh);
1067-
ret = zapi_nexthop_encode(s, &znh, 0/*flags*/,
1068-
0/*message*/);
1067+
ret = zapi_nexthop_encode(s, &znh, 0, message);
10691068
if (ret < 0)
10701069
goto failure;
10711070

zebra/zebra_srte.c

+12-29
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
105105
uint32_t message = 0;
106106
unsigned long nump = 0;
107107
uint8_t num;
108+
struct zapi_nexthop znh;
109+
int ret;
108110

109111
/* Get output stream. */
110112
s = stream_new(ZEBRA_MAX_PACKET_SIZ);
@@ -149,35 +151,11 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
149151
stream_putc(s, 0);
150152
}
151153

152-
stream_putl(s, nhlfe->nexthop->vrf_id);
153-
stream_putc(s, nhlfe->nexthop->type);
154-
switch (nhlfe->nexthop->type) {
155-
case NEXTHOP_TYPE_IPV4:
156-
case NEXTHOP_TYPE_IPV4_IFINDEX:
157-
stream_put_in_addr(s, &nhlfe->nexthop->gate.ipv4);
158-
stream_putl(s, nhlfe->nexthop->ifindex);
159-
break;
160-
case NEXTHOP_TYPE_IFINDEX:
161-
stream_putl(s, nhlfe->nexthop->ifindex);
162-
break;
163-
case NEXTHOP_TYPE_IPV6:
164-
case NEXTHOP_TYPE_IPV6_IFINDEX:
165-
stream_put(s, &nhlfe->nexthop->gate.ipv6, 16);
166-
stream_putl(s, nhlfe->nexthop->ifindex);
167-
break;
168-
default:
169-
/* do nothing */
170-
break;
171-
}
172-
if (nhlfe->nexthop->nh_label) {
173-
stream_putc(s, nhlfe->nexthop->nh_label->num_labels);
174-
if (nhlfe->nexthop->nh_label->num_labels)
175-
stream_put(s,
176-
&nhlfe->nexthop->nh_label->label[0],
177-
nhlfe->nexthop->nh_label->num_labels
178-
* sizeof(mpls_label_t));
179-
} else
180-
stream_putc(s, 0);
154+
zapi_nexthop_from_nexthop(&znh, nhlfe->nexthop);
155+
ret = zapi_nexthop_encode(s, &znh, 0, message);
156+
if (ret < 0)
157+
goto failure;
158+
181159
num++;
182160
}
183161
stream_putc_at(s, nump, num);
@@ -186,6 +164,11 @@ static int zebra_sr_policy_notify_update_client(struct zebra_sr_policy *policy,
186164
client->nh_last_upd_time = monotime(NULL);
187165
client->last_write_cmd = ZEBRA_NEXTHOP_UPDATE;
188166
return zserv_send_message(client, s);
167+
168+
failure:
169+
170+
stream_free(s);
171+
return -1;
189172
}
190173

191174
static void zebra_sr_policy_notify_update(struct zebra_sr_policy *policy)

0 commit comments

Comments
 (0)