@@ -1416,6 +1416,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
1416
1416
case BGP_ATTR_LARGE_COMMUNITIES :
1417
1417
case BGP_ATTR_ORIGINATOR_ID :
1418
1418
case BGP_ATTR_CLUSTER_LIST :
1419
+ case BGP_ATTR_ENCAP :
1419
1420
case BGP_ATTR_OTC :
1420
1421
return BGP_ATTR_PARSE_WITHDRAW ;
1421
1422
case BGP_ATTR_MP_REACH_NLRI :
@@ -2644,39 +2645,33 @@ bgp_attr_ipv6_ext_communities(struct bgp_attr_parser_args *args)
2644
2645
}
2645
2646
2646
2647
/* Parse Tunnel Encap attribute in an UPDATE */
2647
- static int bgp_attr_encap (uint8_t type , struct peer * peer , /* IN */
2648
- bgp_size_t length , /* IN: attr's length field */
2649
- struct attr * attr , /* IN: caller already allocated */
2650
- uint8_t flag , /* IN: attr's flags field */
2651
- uint8_t * startp )
2648
+ static int bgp_attr_encap (struct bgp_attr_parser_args * args )
2652
2649
{
2653
- bgp_size_t total ;
2654
2650
uint16_t tunneltype = 0 ;
2655
-
2656
- total = length + (CHECK_FLAG (flag , BGP_ATTR_FLAG_EXTLEN ) ? 4 : 3 );
2651
+ struct peer * const peer = args -> peer ;
2652
+ struct attr * const attr = args -> attr ;
2653
+ bgp_size_t length = args -> length ;
2654
+ uint8_t type = args -> type ;
2655
+ uint8_t flag = args -> flags ;
2657
2656
2658
2657
if (!CHECK_FLAG (flag , BGP_ATTR_FLAG_TRANS )
2659
2658
|| !CHECK_FLAG (flag , BGP_ATTR_FLAG_OPTIONAL )) {
2660
- zlog_info (
2661
- "Tunnel Encap attribute flag isn't optional and transitive %d" ,
2662
- flag );
2663
- bgp_notify_send_with_data (peer , BGP_NOTIFY_UPDATE_ERR ,
2664
- BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR ,
2665
- startp , total );
2666
- return -1 ;
2659
+ zlog_err ("Tunnel Encap attribute flag isn't optional and transitive %d" ,
2660
+ flag );
2661
+ return bgp_attr_malformed (args , BGP_NOTIFY_UPDATE_OPT_ATTR_ERR ,
2662
+ args -> total );
2667
2663
}
2668
2664
2669
2665
if (BGP_ATTR_ENCAP == type ) {
2670
2666
/* read outer TLV type and length */
2671
2667
uint16_t tlv_length ;
2672
2668
2673
2669
if (length < 4 ) {
2674
- zlog_info (
2670
+ zlog_err (
2675
2671
"Tunnel Encap attribute not long enough to contain outer T,L" );
2676
- bgp_notify_send_with_data (
2677
- peer , BGP_NOTIFY_UPDATE_ERR ,
2678
- BGP_NOTIFY_UPDATE_OPT_ATTR_ERR , startp , total );
2679
- return -1 ;
2672
+ return bgp_attr_malformed (args ,
2673
+ BGP_NOTIFY_UPDATE_OPT_ATTR_ERR ,
2674
+ args -> total );
2680
2675
}
2681
2676
tunneltype = stream_getw (BGP_INPUT (peer ));
2682
2677
tlv_length = stream_getw (BGP_INPUT (peer ));
@@ -2706,13 +2701,11 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
2706
2701
}
2707
2702
2708
2703
if (sublength > length ) {
2709
- zlog_info (
2710
- "Tunnel Encap attribute sub-tlv length %d exceeds remaining length %d" ,
2711
- sublength , length );
2712
- bgp_notify_send_with_data (
2713
- peer , BGP_NOTIFY_UPDATE_ERR ,
2714
- BGP_NOTIFY_UPDATE_OPT_ATTR_ERR , startp , total );
2715
- return -1 ;
2704
+ zlog_err ("Tunnel Encap attribute sub-tlv length %d exceeds remaining length %d" ,
2705
+ sublength , length );
2706
+ return bgp_attr_malformed (args ,
2707
+ BGP_NOTIFY_UPDATE_OPT_ATTR_ERR ,
2708
+ args -> total );
2716
2709
}
2717
2710
2718
2711
/* alloc and copy sub-tlv */
@@ -2760,13 +2753,10 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
2760
2753
2761
2754
if (length ) {
2762
2755
/* spurious leftover data */
2763
- zlog_info (
2764
- "Tunnel Encap attribute length is bad: %d leftover octets" ,
2765
- length );
2766
- bgp_notify_send_with_data (peer , BGP_NOTIFY_UPDATE_ERR ,
2767
- BGP_NOTIFY_UPDATE_OPT_ATTR_ERR ,
2768
- startp , total );
2769
- return -1 ;
2756
+ zlog_err ("Tunnel Encap attribute length is bad: %d leftover octets" ,
2757
+ length );
2758
+ return bgp_attr_malformed (args , BGP_NOTIFY_UPDATE_OPT_ATTR_ERR ,
2759
+ args -> total );
2770
2760
}
2771
2761
2772
2762
return 0 ;
@@ -3690,8 +3680,7 @@ enum bgp_attr_parse_ret bgp_attr_parse(struct peer *peer, struct attr *attr,
3690
3680
case BGP_ATTR_VNC :
3691
3681
#endif
3692
3682
case BGP_ATTR_ENCAP :
3693
- ret = bgp_attr_encap (type , peer , length , attr , flag ,
3694
- startp );
3683
+ ret = bgp_attr_encap (& attr_args );
3695
3684
break ;
3696
3685
case BGP_ATTR_PREFIX_SID :
3697
3686
ret = bgp_attr_prefix_sid (& attr_args );
0 commit comments