mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-04 09:43:05 +00:00
Merge pull request #603 from qlyoung/fix-access-packed-member
*: do not take address of packed member
This commit is contained in:
commit
683f0a1b12
@ -266,7 +266,8 @@ static int
|
||||
bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr)
|
||||
{
|
||||
struct stream *s = BGP_INPUT (peer);
|
||||
struct capability_orf_entry entry;
|
||||
struct capability_mp_data mpc;
|
||||
u_char num;
|
||||
iana_afi_t pkt_afi;
|
||||
afi_t afi;
|
||||
safi_t pkt_safi, safi;
|
||||
@ -277,14 +278,14 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr)
|
||||
int i;
|
||||
|
||||
/* ORF Entry header */
|
||||
bgp_capability_mp_data (s, &entry.mpc);
|
||||
entry.num = stream_getc (s);
|
||||
pkt_afi = entry.mpc.afi;
|
||||
pkt_safi = entry.mpc.safi;
|
||||
bgp_capability_mp_data (s, &mpc);
|
||||
num = stream_getc (s);
|
||||
pkt_afi = mpc.afi;
|
||||
pkt_safi = mpc.safi;
|
||||
|
||||
if (bgp_debug_neighbor_events(peer))
|
||||
zlog_debug ("%s ORF Cap entry for afi/safi: %u/%u",
|
||||
peer->host, entry.mpc.afi, entry.mpc.safi);
|
||||
peer->host, mpc.afi, mpc.safi);
|
||||
|
||||
/* Convert AFI, SAFI to internal values, check. */
|
||||
if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi))
|
||||
@ -295,20 +296,20 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry.mpc.afi = pkt_afi;
|
||||
entry.mpc.safi = safi;
|
||||
mpc.afi = pkt_afi;
|
||||
mpc.safi = safi;
|
||||
|
||||
/* validate number field */
|
||||
if (CAPABILITY_CODE_ORF_LEN + (entry.num * 2) > hdr->length)
|
||||
if (CAPABILITY_CODE_ORF_LEN + (num * 2) > hdr->length)
|
||||
{
|
||||
zlog_info ("%s ORF Capability entry length error,"
|
||||
" Cap length %u, num %u",
|
||||
peer->host, hdr->length, entry.num);
|
||||
peer->host, hdr->length, num);
|
||||
bgp_notify_send (peer, BGP_NOTIFY_OPEN_ERR, BGP_NOTIFY_OPEN_MALFORMED_ATTR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < entry.num ; i++)
|
||||
for (i = 0 ; i < num ; i++)
|
||||
{
|
||||
type = stream_getc(s);
|
||||
mode = stream_getc(s);
|
||||
|
||||
@ -36,18 +36,6 @@ struct capability_mp_data
|
||||
safi_t safi;
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
struct capability_orf_entry
|
||||
{
|
||||
struct capability_mp_data mpc;
|
||||
u_char num;
|
||||
struct {
|
||||
u_char type;
|
||||
u_char mode;
|
||||
} orfs[];
|
||||
} __attribute__ ((packed));
|
||||
#pragma pack()
|
||||
|
||||
struct capability_as4
|
||||
{
|
||||
uint32_t as4;
|
||||
|
||||
@ -434,8 +434,8 @@ int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg)
|
||||
|
||||
if (prefix->state == EIGRP_FSM_STATE_PASSIVE)
|
||||
{
|
||||
if (!eigrp_metrics_is_same(&prefix->reported_metric,
|
||||
&((struct eigrp_neighbor_entry *) prefix->entries->head->data)->total_metric))
|
||||
if (!eigrp_metrics_is_same(prefix->reported_metric,
|
||||
((struct eigrp_neighbor_entry *) prefix->entries->head->data)->total_metric))
|
||||
{
|
||||
prefix->rdistance =
|
||||
prefix->fdistance =
|
||||
|
||||
@ -310,7 +310,7 @@ eigrp_if_up (struct eigrp_interface *ei)
|
||||
pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;
|
||||
|
||||
pe->state = EIGRP_FSM_STATE_PASSIVE;
|
||||
pe->fdistance = eigrp_calculate_metrics (eigrp, &metric);
|
||||
pe->fdistance = eigrp_calculate_metrics (eigrp, metric);
|
||||
pe->req_action |= EIGRP_FSM_NEED_UPDATE;
|
||||
eigrp_prefix_entry_add (eigrp->topology_table, pe);
|
||||
listnode_add(eigrp->topology_changes_internalIPV4, pe);
|
||||
@ -319,7 +319,7 @@ eigrp_if_up (struct eigrp_interface *ei)
|
||||
ne->ei = ei;
|
||||
ne->reported_metric = metric;
|
||||
ne->total_metric = metric;
|
||||
ne->distance = eigrp_calculate_metrics (eigrp, &metric);
|
||||
ne->distance = eigrp_calculate_metrics (eigrp, metric);
|
||||
ne->reported_distance = 0;
|
||||
ne->prefix = pe;
|
||||
ne->adv_router = eigrp->neighbor_self;
|
||||
|
||||
@ -387,29 +387,29 @@ eigrp_network_unset(struct eigrp *eigrp, struct prefix_ipv4 *p)
|
||||
}
|
||||
|
||||
u_int32_t
|
||||
eigrp_calculate_metrics(struct eigrp *eigrp, struct eigrp_metrics *metric)
|
||||
eigrp_calculate_metrics(struct eigrp *eigrp, struct eigrp_metrics metric)
|
||||
{
|
||||
uint64_t temp_metric;
|
||||
temp_metric = 0;
|
||||
|
||||
if(metric->delay == EIGRP_MAX_METRIC)
|
||||
if(metric.delay == EIGRP_MAX_METRIC)
|
||||
return EIGRP_MAX_METRIC;
|
||||
|
||||
// EIGRP Metric = {K1*BW+[(K2*BW)/(256-load)]+(K3*delay)}*{K5/(reliability+K4)}
|
||||
|
||||
if (eigrp->k_values[0])
|
||||
temp_metric += (eigrp->k_values[0] * metric->bandwith);
|
||||
temp_metric += (eigrp->k_values[0] * metric.bandwith);
|
||||
if (eigrp->k_values[1])
|
||||
temp_metric += ((eigrp->k_values[1] * metric->bandwith)
|
||||
/ (256 - metric->load));
|
||||
temp_metric += ((eigrp->k_values[1] * metric.bandwith)
|
||||
/ (256 - metric.load));
|
||||
if (eigrp->k_values[2])
|
||||
temp_metric += (eigrp->k_values[2] * metric->delay);
|
||||
temp_metric += (eigrp->k_values[2] * metric.delay);
|
||||
if (eigrp->k_values[3] && !eigrp->k_values[4])
|
||||
temp_metric *= eigrp->k_values[3];
|
||||
if (!eigrp->k_values[3] && eigrp->k_values[4])
|
||||
temp_metric *= (eigrp->k_values[4] / metric->reliability);
|
||||
temp_metric *= (eigrp->k_values[4] / metric.reliability);
|
||||
if (eigrp->k_values[3] && eigrp->k_values[4])
|
||||
temp_metric *= ((eigrp->k_values[4] / metric->reliability)
|
||||
temp_metric *= ((eigrp->k_values[4] / metric.reliability)
|
||||
+ eigrp->k_values[3]);
|
||||
|
||||
if (temp_metric <= EIGRP_MAX_METRIC)
|
||||
@ -432,21 +432,21 @@ eigrp_calculate_total_metrics(struct eigrp *eigrp,
|
||||
entry->total_metric.bandwith =
|
||||
entry->total_metric.bandwith > bw ? bw : entry->total_metric.bandwith;
|
||||
|
||||
return eigrp_calculate_metrics(eigrp, &entry->total_metric);
|
||||
return eigrp_calculate_metrics(eigrp, entry->total_metric);
|
||||
}
|
||||
|
||||
u_char
|
||||
eigrp_metrics_is_same(struct eigrp_metrics *metric1,
|
||||
struct eigrp_metrics *metric2)
|
||||
eigrp_metrics_is_same(struct eigrp_metrics metric1,
|
||||
struct eigrp_metrics metric2)
|
||||
{
|
||||
if ((metric1->bandwith == metric2->bandwith)
|
||||
&& (metric1->delay == metric2->delay)
|
||||
&& (metric1->hop_count == metric2->hop_count)
|
||||
&& (metric1->load == metric2->load)
|
||||
&& (metric1->reliability == metric2->reliability)
|
||||
&& (metric1->mtu[0] == metric2->mtu[0])
|
||||
&& (metric1->mtu[1] == metric2->mtu[1])
|
||||
&& (metric1->mtu[2] == metric2->mtu[2]))
|
||||
if ((metric1.bandwith == metric2.bandwith)
|
||||
&& (metric1.delay == metric2.delay)
|
||||
&& (metric1.hop_count == metric2.hop_count)
|
||||
&& (metric1.load == metric2.load)
|
||||
&& (metric1.reliability == metric2.reliability)
|
||||
&& (metric1.mtu[0] == metric2.mtu[0])
|
||||
&& (metric1.mtu[1] == metric2.mtu[1])
|
||||
&& (metric1.mtu[2] == metric2.mtu[2]))
|
||||
return 1;
|
||||
|
||||
return 0; // if different
|
||||
|
||||
@ -43,9 +43,9 @@ extern int eigrp_if_drop_allspfrouters (struct eigrp *top, struct prefix *p,
|
||||
unsigned int ifindex);
|
||||
extern void eigrp_adjust_sndbuflen (struct eigrp *, unsigned int);
|
||||
|
||||
extern u_int32_t eigrp_calculate_metrics (struct eigrp *, struct eigrp_metrics *);
|
||||
extern u_int32_t eigrp_calculate_metrics (struct eigrp *, struct eigrp_metrics);
|
||||
extern u_int32_t eigrp_calculate_total_metrics (struct eigrp *, struct eigrp_neighbor_entry *);
|
||||
extern u_char eigrp_metrics_is_same(struct eigrp_metrics *,struct eigrp_metrics *);
|
||||
extern u_char eigrp_metrics_is_same(struct eigrp_metrics, struct eigrp_metrics);
|
||||
extern void eigrp_external_routes_refresh (struct eigrp *, int);
|
||||
|
||||
#endif /* EIGRP_NETWORK_H_ */
|
||||
|
||||
@ -423,24 +423,24 @@ eigrp_topology_update_distance(struct eigrp_fsm_action_message *msg)
|
||||
if (msg->data_type == EIGRP_TLV_IPv4_INT)
|
||||
{
|
||||
int_data = msg->data.ipv4_int_type;
|
||||
if (eigrp_metrics_is_same(&int_data->metric,&entry->reported_metric))
|
||||
if (eigrp_metrics_is_same(int_data->metric, entry->reported_metric))
|
||||
{
|
||||
return 0; // No change
|
||||
}
|
||||
change =
|
||||
entry->reported_distance
|
||||
< eigrp_calculate_metrics(eigrp, &int_data->metric) ? 1 :
|
||||
< eigrp_calculate_metrics(eigrp, int_data->metric) ? 1 :
|
||||
entry->reported_distance
|
||||
> eigrp_calculate_metrics(eigrp, &int_data->metric) ? 2 : 3; // Increase : Decrease : No change
|
||||
> eigrp_calculate_metrics(eigrp, int_data->metric) ? 2 : 3; // Increase : Decrease : No change
|
||||
entry->reported_metric = int_data->metric;
|
||||
entry->reported_distance =
|
||||
eigrp_calculate_metrics(eigrp, &int_data->metric);
|
||||
eigrp_calculate_metrics(eigrp, int_data->metric);
|
||||
entry->distance = eigrp_calculate_total_metrics(eigrp, entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
ext_data = msg->data.ipv4_ext_data;
|
||||
if (eigrp_metrics_is_same (&ext_data->metric, &entry->reported_metric))
|
||||
if (eigrp_metrics_is_same (ext_data->metric, entry->reported_metric))
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
||||
@ -344,7 +344,7 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *
|
||||
ne->reported_metric = tlv->metric;
|
||||
ne->reported_distance =
|
||||
eigrp_calculate_metrics(eigrp,
|
||||
&tlv->metric);
|
||||
tlv->metric);
|
||||
/*
|
||||
* Filtering
|
||||
*/
|
||||
|
||||
@ -509,7 +509,7 @@ eigrp_redistribute_set (struct eigrp *eigrp, int type, struct eigrp_metrics metr
|
||||
|
||||
if (eigrp_is_type_redistributed (type))
|
||||
{
|
||||
if (eigrp_metrics_is_same(&metric, &eigrp->dmetric[type]))
|
||||
if (eigrp_metrics_is_same(metric, eigrp->dmetric[type]))
|
||||
{
|
||||
eigrp->dmetric[type] = metric;
|
||||
}
|
||||
|
||||
@ -1315,7 +1315,8 @@ process_lsp (int level, struct isis_circuit *circuit, const u_char *ssnpa)
|
||||
/* Checksum sanity check - FIXME: move to correct place */
|
||||
/* 12 = sysid+pdu+remtime */
|
||||
if (iso_csum_verify (STREAM_PNT (circuit->rcv_stream) + 4,
|
||||
pdu_len - 12, &hdr->checksum))
|
||||
pdu_len - 12, hdr->checksum,
|
||||
offsetof(struct isis_link_state_hdr, checksum) - 4))
|
||||
{
|
||||
zlog_debug ("ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04x",
|
||||
circuit->area->area_tag,
|
||||
|
||||
@ -46,14 +46,14 @@
|
||||
*/
|
||||
|
||||
int
|
||||
iso_csum_verify (u_char * buffer, int len, uint16_t * csum)
|
||||
iso_csum_verify (u_char * buffer, int len, uint16_t csum, int offset)
|
||||
{
|
||||
u_int16_t checksum;
|
||||
u_int32_t c0;
|
||||
u_int32_t c1;
|
||||
|
||||
c0 = *csum & 0xff00;
|
||||
c1 = *csum & 0x00ff;
|
||||
c0 = csum & 0xff00;
|
||||
c1 = csum & 0x00ff;
|
||||
|
||||
/*
|
||||
* If both are zero return correct
|
||||
@ -67,11 +67,8 @@ iso_csum_verify (u_char * buffer, int len, uint16_t * csum)
|
||||
if (c0 == 0 || c1 == 0)
|
||||
return 1;
|
||||
|
||||
/* Offset of checksum from the start of the buffer */
|
||||
int offset = (u_char *) csum - buffer;
|
||||
|
||||
checksum = fletcher_checksum(buffer, len, offset);
|
||||
if (checksum == *csum)
|
||||
if (checksum == csum)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -23,6 +23,6 @@
|
||||
#ifndef _ZEBRA_ISO_CSUM_H
|
||||
#define _ZEBRA_ISO_CSUM_H
|
||||
|
||||
int iso_csum_verify (u_char * buffer, int len, uint16_t * csum);
|
||||
int iso_csum_verify (u_char * buffer, int len, uint16_t csum, int offset);
|
||||
|
||||
#endif /* _ZEBRA_ISO_CSUM_H */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user