>Number:         6406
>Category:       system
>Synopsis:       bgpd won't look at instructions for specific static routes in 
>'network' statements if 'network inet static' is also defined
>Confidential:   yes
>Severity:       serious
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Thu Jun 17 04:10:01 GMT 2010
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        
>Organization:
>Environment:
        System      : OpenBSD 4.7
        Details     : OpenBSD 4.7-current (GENERIC.MP) #12: Wed May 26 13:20:01 
MDT 2010
                         
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
A configuration like this:

network 198.7.128.0/21 set community 27008:300
network inet static set community 27008:299

with a static route of the same name:

route -net 198.7.128.0/21 66.39.199.199

will always cause 198.7.128.0/21 to get propagated with 27008:299 community, 
and never 27008:300 (no matter the order of the network lines in bgpd.conf)

The problem is that bgpd_redistribute is "hardwired" to setup the same sets of 
attributes, one set for all connected and another for all static routes, no 
matter what else the bgpd.conf actually says.  The RDE always reflects 
hardcoded settings, not bgpd.conf settings.  In my environment, I have static 
routes taht I want covered by the blanket network statement, and static routes 
that I want setup differently.

>How-To-Repeat:
Define a static route, a network for that specific route, and network inet 
static for the rest of your generic static routes, watch the custom definitions 
in the specific network line get ignored

>Fix:
The problem behavior is reinforced for connected and static routes throughout 
kroute.c.  Its messy and calls bgpd_reconfigure all over the place.

A number of kroute.c functions end up calling kr_redistribute, followed by 
bgpd_redistribute, through kr_insert, kr_remove, etc... In its current state, 
bgpd_redistribute is dumb and should run before the flexible RDE configurator.  
That way the flexible one can simply override the damage from bgpd_redistribute

I moved the kr_init call (which ultimately calls *_redistribute) before the 
flexible RDE configuratior (reconfigure) in the main function.  I changed 
reconfigure itself to call kr_reload before the flexible RDE configurator chunk 
of code actually runs.  This "fixes" the problem described in this bug report 
with static routes, and allows my config of specific static routes to override 
the fixed attribute sets.  But there is likely a similar problem with connected 
routes.

A better solution may be for bgpd_redistribute to return(1) for routes already 
defined in the RDE.  Perhaps add a new IMSG that tells bgpd_redistribute to 
ignore specific routes?

Index: bgpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.c,v
retrieving revision 1.155
diff -u bgpd.c
--- bgpd.c      3 Mar 2010 09:40:56 -0000       1.155
+++ bgpd.c      17 Jun 2010 01:53:38 -0000
@@ -250,10 +250,10 @@
        imsg_init(ibuf_se, pipe_m2s[0]);
        imsg_init(ibuf_rde, pipe_m2r[0]);
        mrt_init(ibuf_rde, ibuf_se);
-       quit = reconfigure(conffile, &conf, &mrt_l, &peer_l, rules_l);
        if ((rfd = kr_init(!(conf.flags & BGPD_FLAG_NO_FIB_UPDATE),
            conf.rtableid)) == -1)
                quit = 1;
+       quit = reconfigure(conffile, &conf, &mrt_l, &peer_l, rules_l);
        if (pftable_clear_all() != 0)
                quit = 1;
 
@@ -486,6 +486,10 @@
                free(rr);
        }
 
+       /* redistribute list needs to be reloaded too */
+       if (kr_reload() == -1)
+               return (-1);
+
        /* networks for the RDE */
        while ((n = TAILQ_FIRST(&net_l)) != NULL) {
                if (imsg_compose(ibuf_rde, IMSG_NETWORK_ADD, 0, 0, -1,
@@ -500,10 +504,6 @@
                filterset_free(&n->net.attrset);
                free(n);
        }
-
-       /* redistribute list needs to be reloaded too */
-       if (kr_reload() == -1)
-               return (-1);
 
        /* filters for the RDE */
        while ((r = TAILQ_FIRST(rules_l)) != NULL) {


dmesg:
OpenBSD 4.7-current (GENERIC.MP) #12: Wed May 26 13:20:01 MDT 2010
    [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 2126909440 (2028MB)
avail mem = 2056597504 (1961MB)
RTC BIOS diagnostic error 80<clock_battery>
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe43d0 (32 entries)
bios0: vendor Intel Corp. version "MQ96510J.86A.1687.2007.0510.0258" date 
05/10/2007
bios0: Intel Corporation DG965SS
acpi0 at bios0: rev 0
acpi0: tables DSDT FACP APIC WDDT MCFG ASF! HPET
acpi0: wakeup devices SLPB(S4) P32_(S4) UAR1(S4) UAR2(S4) ILAN(S4) PEGP(S4) 
PEX0(S4) PEX1(S4) PEX2(S4) PEX3(S4) PEX4(S4) PEX5(S4) UHC1(S3) UHC2(S3) 
UHC3(S3) UHC4(S3) EHCI(S3) EHC2(S3) UH42(S3) UHC5(S3) AZAL(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Pentium(R) CPU E5200 @ 2.50GHz, 2497.88 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,TM2,SSSE3,NXE,LONG
cpu0: 2MB 64b/line 8-way L2 cache
cpu0: apic clock running at 199MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Pentium(R) CPU E5200 @ 2.50GHz, 2497.51 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,TM2,SSSE3,NXE,LONG
cpu1: 2MB 64b/line 8-way L2 cache
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 2
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 7 (P32_)
acpiprt2 at acpi0: bus 2 (PEX0)
acpiprt3 at acpi0: bus 3 (PEX1)
acpiprt4 at acpi0: bus 4 (PEX2)
acpiprt5 at acpi0: bus 5 (PEX3)
acpiprt6 at acpi0: bus 6 (PEX4)
acpiprt7 at acpi0: bus -1 (PEX5)
acpicpu0 at acpi0
acpicpu1 at acpi0
acpibtn0 at acpi0: SLPB
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82G965 Host" rev 0x02
ppb0 at pci0 dev 1 function 0 "Intel 82G965 PCIE" rev 0x02: apic 2 int 16 (irq 
255)
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "ATI Radeon HD 4350" rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
radeondrm0 at vga1: apic 2 int 16 (irq 11)
drm0 at radeondrm0
azalia0 at pci1 dev 0 function 1 "ATI Radeon HD 4000 HD Audio" rev 0x00: apic 2 
int 17 (irq 9)
azalia0: no supported codecs
azalia0: initialization failure, detaching
"Intel 82G965 HECI" rev 0x02 at pci0 dev 3 function 0 not configured
em0 at pci0 dev 25 function 0 "Intel ICH8 IGP C" rev 0x02: apic 2 int 20 (irq 
10), address 00:19:d1:9b:a3:bf
uhci0 at pci0 dev 26 function 0 "Intel 82801H USB" rev 0x02: apic 2 int 16 (irq 
11)
uhci1 at pci0 dev 26 function 1 "Intel 82801H USB" rev 0x02: apic 2 int 21 (irq 
11)
ehci0 at pci0 dev 26 function 7 "Intel 82801H USB" rev 0x02: apic 2 int 18 (irq 
9)
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia1 at pci0 dev 27 function 0 "Intel 82801H HD Audio" rev 0x02: apic 2 int 
22 (irq 10)
azalia1: codecs: Sigmatel STAC9227X
audio0 at azalia1
ppb1 at pci0 dev 28 function 0 "Intel 82801H PCIE" rev 0x02: apic 2 int 17 (irq 
255)
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 1 "Intel 82801H PCIE" rev 0x02: apic 2 int 16 (irq 
255)
pci3 at ppb2 bus 3
pciide0 at pci3 dev 0 function 0 "Marvell 88SE6101 IDE" rev 0xb1: DMA 
(unsupported), channel 0 configured to native-PCI, channel 1 configured to 
native-PCI
pciide0: using apic 2 int 17 (irq 9) for native-PCI interrupt
pciide0: channel 0 ignored (not responding; disabled or no drives?)
pciide0: channel 1 ignored (not responding; disabled or no drives?)
ppb3 at pci0 dev 28 function 2 "Intel 82801H PCIE" rev 0x02: apic 2 int 18 (irq 
255)
pci4 at ppb3 bus 4
ppb4 at pci0 dev 28 function 3 "Intel 82801H PCIE" rev 0x02: apic 2 int 19 (irq 
255)
pci5 at ppb4 bus 5
ppb5 at pci0 dev 28 function 4 "Intel 82801H PCIE" rev 0x02: apic 2 int 17 (irq 
255)
pci6 at ppb5 bus 6
uhci2 at pci0 dev 29 function 0 "Intel 82801H USB" rev 0x02: apic 2 int 23 (irq 
11)
uhci3 at pci0 dev 29 function 1 "Intel 82801H USB" rev 0x02: apic 2 int 19 (irq 
11)
uhci4 at pci0 dev 29 function 2 "Intel 82801H USB" rev 0x02: apic 2 int 18 (irq 
9)
ehci1 at pci0 dev 29 function 7 "Intel 82801H USB" rev 0x02: apic 2 int 23 (irq 
11)
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb6 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0xf2
pci7 at ppb6 bus 7
"TI TSB43AB22 FireWire" rev 0x00 at pci7 dev 3 function 0 not configured
pcib0 at pci0 dev 31 function 0 "Intel 82801H LPC" rev 0x02
ahci0 at pci0 dev 31 function 2 "Intel 82801H AHCI" rev 0x02: apic 2 int 19 
(irq 11), AHCI 1.1
scsibus0 at ahci0: 32 targets
sd0 at scsibus0 targ 0 lun 0: <ATA, ST3200820AS, 3.AA> SCSI3 0/direct fixed
sd0: 190782MB, 512 bytes/sec, 390721968 sec total
cd0 at scsibus0 targ 1 lun 0: <HL-DT-ST, DVDRAM GH22LS40, LL00> ATAPI 5/cdrom 
removable
ichiic0 at pci0 dev 31 function 3 "Intel 82801H SMBus" rev 0x02: apic 2 int 21 
(irq 11)
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 1GB DDR2 SDRAM non-parity PC2-6400CL5
spdmem1 at iic0 addr 0x52: 1GB DDR2 SDRAM non-parity PC2-6400CL5
usb2 at uhci0: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci1: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci2: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb5 at uhci3: USB revision 1.0
uhub5 at usb5 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb6 at uhci4: USB revision 1.0
uhub6 at usb6 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
spkr0 at pcppi0
mtrr: Pentium Pro MTRR support
uplcom0 at uhub3 port 1 "Prolific Technology Inc. USB-Serial Controller D" rev 
1.10/4.00 addr 2
ucom0 at uplcom0
uhidev0 at uhub5 port 2 configuration 1 interface 0 "Logitech USB-PS/2 Optical 
Mouse" rev 2.00/11.10 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
uhidev1 at uhub4 port 2 configuration 1 interface 0 "Microsoft Wired Keyboard 
400" rev 1.10/1.10 addr 2
uhidev1: iclass 3/1
ukbd0 at uhidev1: 8 modifier keys, 6 key codes
wskbd0 at ukbd0: console keyboard, using wsdisplay0
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
root on sd0a swap on sd0b dump on sd0b

usbdevs:
Controller /dev/usb0:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), 
Intel(0x8086), rev 1.00
 port 1 powered
 port 2 powered
 port 3 powered
 port 4 powered
Controller /dev/usb1:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), 
Intel(0x8086), rev 1.00
 port 1 powered
 port 2 powered
 port 3 powered
 port 4 powered
 port 5 powered
 port 6 powered
Controller /dev/usb2:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), 
Intel(0x8086), rev 1.00
 port 1 powered
 port 2 powered
Controller /dev/usb3:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), 
Intel(0x8086), rev 1.00
 port 1 addr 2: full speed, power 100 mA, config 1, USB-Serial Controller 
D(0x2303), Prolific Technology Inc.(0x067b), rev 4.00
 port 2 powered
Controller /dev/usb4:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), 
Intel(0x8086), rev 1.00
 port 1 powered
 port 2 addr 2: low speed, power 100 mA, config 1, Wired Keyboard 400(0x0752), 
Microsoft(0x045e), rev 1.10
Controller /dev/usb5:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), 
Intel(0x8086), rev 1.00
 port 1 powered
 port 2 addr 2: low speed, power 98 mA, config 1, USB-PS/2 Optical 
Mouse(0xc00e), Logitech(0x046d), rev 11.10


>Release-Note:
>Audit-Trail:
>Unformatted:

Reply via email to