Revision bd2d8190 proto/bgp/attrs.c

View differences:

proto/bgp/attrs.c
297 297
  return b;
298 298
}
299 299

  
300
static int
301
bgp_export_check(struct bgp_proto *p, ea_list *new)
302
{
303
  eattr *a;
304
  struct adata *d;
305

  
306
  /* Check if next hop is valid */
307
  a = ea_find(new, EA_CODE(EAP_BGP, BA_NEXT_HOP));
308
  if (!a || ipa_equal(p->next_hop, *(ip_addr *)a->u.ptr))
309
    {
310
      DBG("\tInvalid NEXT_HOP\n");
311
      return 0;
312
    }
313

  
314
  /* Check if we aren't forbidden to export the route by communities */
315
  a = ea_find(new, EA_CODE(EAP_BGP, BA_COMMUNITY));
316
  if (a)
317
    {
318
      d = a->u.ptr;
319
      if (int_set_contains(d, BGP_COMM_NO_ADVERTISE))
320
	{
321
	  DBG("\tNO_ADVERTISE\n");
322
	  return 0;
323
	}
324
      if (!p->is_internal &&
325
	  (int_set_contains(d, BGP_COMM_NO_EXPORT) ||
326
	   int_set_contains(d, BGP_COMM_NO_EXPORT_SUBCONFED)))
327
	{
328
	  DBG("\tNO_EXPORT\n");
329
	  return 0;
330
	}
331
    }
332

  
333
  return 1;
334
}
335

  
300 336
static struct bgp_bucket *
301 337
bgp_get_bucket(struct bgp_proto *p, ea_list *old, ea_list *tmp, int originate)
302 338
{
......
375 411
	return NULL;
376 412
      }
377 413

  
378
  /* Check if next hop is valid */
379
  a = ea_find(new, EA_CODE(EAP_BGP, BA_NEXT_HOP));
380
  ASSERT(a);
381
  if (ipa_equal(p->next_hop, *(ip_addr *)a->u.ptr))
414
  if (!bgp_export_check(p, new))
382 415
    return NULL;
383 416

  
384 417
  /* Create new bucket */

Also available in: Unified diff