]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_attr.c
Merge pull request #11146 from NicolasDichtel/master
[mirror_frr.git] / bgpd / bgp_attr.c
index f45362f81164e16409f725078429c081ce20f495..6784e632062c389dac1429130262c108b1f695a3 100644 (file)
@@ -951,7 +951,8 @@ struct attr *bgp_attr_intern(struct attr *attr)
 }
 
 /* Make network statement's attribute. */
-struct attr *bgp_attr_default_set(struct attr *attr, uint8_t origin)
+struct attr *bgp_attr_default_set(struct attr *attr, struct bgp *bgp,
+                                 uint8_t origin)
 {
        memset(attr, 0, sizeof(struct attr));
 
@@ -965,6 +966,7 @@ struct attr *bgp_attr_default_set(struct attr *attr, uint8_t origin)
        attr->label = MPLS_INVALID_LABEL;
        attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP);
        attr->mp_nexthop_len = IPV6_MAX_BYTELEN;
+       attr->local_pref = bgp->default_local_pref;
 
        return attr;
 }
@@ -980,7 +982,7 @@ struct attr *bgp_attr_aggregate_intern(
        struct attr *new;
        int ret;
 
-       memset(&attr, 0, sizeof(struct attr));
+       memset(&attr, 0, sizeof(attr));
 
        /* Origin attribute. */
        attr.origin = origin;
@@ -1043,7 +1045,7 @@ struct attr *bgp_attr_aggregate_intern(
                struct attr attr_tmp = attr;
                struct bgp_path_info rmap_path;
 
-               memset(&rmap_path, 0, sizeof(struct bgp_path_info));
+               memset(&rmap_path, 0, sizeof(rmap_path));
                rmap_path.peer = bgp->peer_self;
                rmap_path.attr = &attr_tmp;
 
@@ -1605,9 +1607,9 @@ enum bgp_attr_parse_ret bgp_attr_nexthop_valid(struct peer *peer,
        in_addr_t nexthop_h;
 
        nexthop_h = ntohl(attr->nexthop.s_addr);
-       if ((IPV4_NET0(nexthop_h) || IPV4_NET127(nexthop_h)
-            || IPV4_CLASS_DE(nexthop_h))
-           && !BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) {
+       if ((IPV4_NET0(nexthop_h) || IPV4_NET127(nexthop_h) ||
+            !ipv4_unicast_valid(&attr->nexthop)) &&
+           !BGP_DEBUG(allow_martians, ALLOW_MARTIANS)) {
                uint8_t data[7]; /* type(2) + length(1) + nhop(4) */
                char buf[INET_ADDRSTRLEN];
 
@@ -4430,7 +4432,7 @@ void bgp_packet_mpunreach_prefix(struct stream *s, const struct prefix *p,
                                 bool addpath_capable, uint32_t addpath_tx_id,
                                 struct attr *attr)
 {
-       uint8_t wlabel[3] = {0x80, 0x00, 0x00};
+       uint8_t wlabel[4] = {0x80, 0x00, 0x00};
 
        if (safi == SAFI_LABELED_UNICAST) {
                label = (mpls_label_t *)wlabel;