summaryrefslogtreecommitdiff
path: root/net/quagga/files/patch-cvs-1-bgpd-rm-assert
blob: 9795729483407f030c57f8b82d82c757d25c0fe0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
--- bgpd/ChangeLog.orig	23 Aug 2007 23:22:02 -0000	1.140
+++ bgpd/ChangeLog	27 Aug 2007 11:48:47 -0000
@@ -1,3 +1,24 @@
+2007-08-27 Paul Jakma <paul.jakma@sun.com>
+
+	* bgp_route.c: (bgp_announce_check) Fix bug #398, slight
+	  modification of Vladimir Ivanov's suggested fix - to keep
+	  memory alloc conditional.
+	  (bgp_process_announce_selected) Don't take struct attr as
+	  argument, none of the callers need it and it needlessly
+	  distances allocation from use.
+	  Free the extended attr, the attr itself is on the stack. 
+	  Fix bad indentation.
+	* bgp_attr.c: (bgp_packet_attribute) Remove incorrect assert,
+	  and adjust conditional to test attr->extra, diagnosis by
+	  Vladimir Ivanov in bug #398.
+
+2007-08-27 Vladimir Ivanov <wawa@yandex-team.ru>
+
+	* bgp_route.c: (bgp_announce_check_rsclient) copy of
+	  ri->attr is no longer deep enough, due to addition of
+	  attr->extra. It should use bgp_attr_dup, as
+	  bgp_announce_check() does.
+
 2007-08-23 Paul Jakma <paul.jakma@sun.com>
 
 	* bgp_regex.c: (bgp_regcomp) Pass NOSUB flag to regcomp to
--- bgpd/bgp_attr.c.orig	6 Aug 2007 15:24:51 -0000	1.22
+++ bgpd/bgp_attr.c	27 Aug 2007 11:48:47 -0000
@@ -1673,8 +1673,6 @@ bgp_packet_attribute (struct bgp *bgp, s
       && from
       && peer_sort (from) == BGP_PEER_IBGP)
     {
-      assert (attr->extra);
-      
       /* Originator ID. */
       stream_putc (s, BGP_ATTR_FLAG_OPTIONAL);
       stream_putc (s, BGP_ATTR_ORIGINATOR_ID);
@@ -1689,7 +1687,7 @@ bgp_packet_attribute (struct bgp *bgp, s
       stream_putc (s, BGP_ATTR_FLAG_OPTIONAL);
       stream_putc (s, BGP_ATTR_CLUSTER_LIST);
       
-      if (attr->extra->cluster)
+      if (attr->extra && attr->extra->cluster)
 	{
 	  stream_putc (s, attr->extra->cluster->length + 4);
 	  /* If this peer configuration's parent BGP has cluster_id. */
--- bgpd/bgp_route.c.orig	6 Aug 2007 15:24:51 -0000	1.63
+++ bgpd/bgp_route.c	27 Aug 2007 11:48:48 -0000
@@ -1045,20 +1045,18 @@ bgp_announce_check (struct bgp_info *ri,
       || (ri->extra && ri->extra->suppress) )
     {
       struct bgp_info info;
-      struct attr dummy_attr;
+      struct attr dummy_attr = { 0 };
       
       info.peer = peer;
       info.attr = attr;
-      
 
       /* The route reflector is not allowed to modify the attributes
 	 of the reflected IBGP routes. */
       if (peer_sort (from) == BGP_PEER_IBGP 
 	  && peer_sort (peer) == BGP_PEER_IBGP)
 	{
-	  dummy_attr.extra = NULL;
 	  bgp_attr_dup (&dummy_attr, attr);
-	  info.attr = &dummy_attr; 
+	  info.attr = &dummy_attr;
 	}
 
       SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT); 
@@ -1070,7 +1068,8 @@ bgp_announce_check (struct bgp_info *ri,
 
       peer->rmap_type = 0;
       
-      bgp_attr_extra_free (&dummy_attr);
+      if (dummy_attr.extra)
+        bgp_attr_extra_free (&dummy_attr);
       
       if (ret == RMAP_DENYMATCH)
 	{
@@ -1173,7 +1172,7 @@ bgp_announce_check_rsclient (struct bgp_
 #endif /* BGP_SEND_ASPATH_CHECK */
 
   /* For modify attribute, copy it to temporary structure. */
-  *attr = *ri->attr;
+  bgp_attr_dup (attr, ri->attr);
 
   /* next-hop-set */
   if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
@@ -1375,21 +1374,22 @@ bgp_best_selection (struct bgp *bgp, str
 
 static int
 bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
-        struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi)
-    {
+                               struct bgp_node *rn, afi_t afi, safi_t safi)
+{
   struct prefix *p;
+  struct attr attr = { 0 };
 
   p = &rn->p;
 
-      /* Announce route to Established peer. */
-      if (peer->status != Established)
+  /* Announce route to Established peer. */
+  if (peer->status != Established)
     return 0;
 
-      /* Address family configuration check. */
-      if (! peer->afc_nego[afi][safi])
+  /* Address family configuration check. */
+  if (! peer->afc_nego[afi][safi])
     return 0;
 
-      /* First update is deferred until ORF or ROUTE-REFRESH is received */
+  /* First update is deferred until ORF or ROUTE-REFRESH is received */
   if (CHECK_FLAG (peer->af_sflags[afi][safi],
       PEER_STATUS_ORF_WAIT_REFRESH))
     return 0;
@@ -1399,21 +1399,24 @@ bgp_process_announce_selected (struct pe
       case BGP_TABLE_MAIN:
       /* Announcement to peer->conf.  If the route is filtered,
          withdraw it. */
-        if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi))
-          bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected);
+        if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
+          bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
         else
           bgp_adj_out_unset (rn, peer, p, afi, safi);
         break;
       case BGP_TABLE_RSCLIENT:
         /* Announcement to peer->conf.  If the route is filtered, 
            withdraw it. */
-        if (selected && bgp_announce_check_rsclient
-              (selected, peer, p, attr, afi, safi))
-          bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected);
-      else
-	bgp_adj_out_unset (rn, peer, p, afi, safi);
+        if (selected && 
+            bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
+          bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
+        else
+	  bgp_adj_out_unset (rn, peer, p, afi, safi);
         break;
     }
+  
+  bgp_attr_extra_free (&attr);
+  
   return 0;
 }
 
@@ -1463,8 +1466,7 @@ bgp_process_rsclient (struct work_queue 
 	      bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
 	    }
 
-	  bgp_process_announce_selected (rsclient, new_select, rn, &attr,
-					 afi, safi);
+	  bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
 	}
     }
   else
@@ -1476,8 +1478,7 @@ bgp_process_rsclient (struct work_queue 
 	  bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
 	  bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
 	}
-      bgp_process_announce_selected (rsclient, new_select, rn,
-				     &attr, afi, safi);
+      bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
     }
 
   if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
@@ -1503,9 +1504,6 @@ bgp_process_main (struct work_queue *wq,
   struct bgp_info_pair old_and_new;
   struct listnode *node, *nnode;
   struct peer *peer;
-  struct attr attr;
-  
-  memset (&attr, 0, sizeof (struct attr));
   
   /* Best path selection. */
   bgp_best_selection (bgp, rn, &old_and_new);
@@ -1537,7 +1535,7 @@ bgp_process_main (struct work_queue *wq,
   /* Check each BGP peer. */
   for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
     {
-      bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi);
+      bgp_process_announce_selected (peer, new_select, rn, afi, safi);
     }
 
   /* FIB update. */
@@ -1562,8 +1560,6 @@ bgp_process_main (struct work_queue *wq,
   if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
     bgp_info_reap (rn, old_select);
   
-  bgp_attr_extra_free (&attr);
-  
   UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
   return WQ_SUCCESS;
 }
@@ -6214,7 +6210,7 @@ bgp_show_table (struct vty *vty, struct 
 	      {
 		struct route_map *rmap = output_arg;
 		struct bgp_info binfo;
-		struct attr dummy_attr; 
+		struct attr dummy_attr = { 0 }; 
 		int ret;
 
 		bgp_attr_dup (&dummy_attr, ri->attr);