So, after working with JTAC yesterday, "I", as in I really didn't need JTAC since I figured out the issue on my own.. realized that my firewall filter was a bit redundant and was lacking a "permit any" statement.
OSPF adjacency was breaking because the firewall filter was taking the "else" traffic (term DEFAULT) and sending it to routing-instance PATH-2, which didn't help either way since it was sending traffic right back to SW-2, something a "then accept" statement would have done easily
So, to repair the issue..
New SW-2 & RTR-2 corrected configlets:
delete routing-instances PATH-2
delete firewall family inet filter FBF-TEST term DEFAULT
set firewall family inet filter FBF-TEST term PERMIT-ANY then accept
New config snips for SW-2:
routing-options {
nonstop-routing;
interface-routes {
rib-group inet STAGING-RIB;
}
static {
route 10.100.190.0/24 next-hop 10.100.100.2;
route 10.100.191.0/24 next-hop 10.100.100.2;
}
rib-groups {
STAGING-RIB {
import-rib [ inet.0 PATH-1.inet.0 ];
}
}
router-id 10.100.254.1;
}
firewall {
family inet {
filter FBF-TEST {
term TERM-1 {
from {
source-address {
10.100.190.0/24;
10.100.191.0/24;
}
}
then {
routing-instance PATH-1;
}
}
term PERMIT-ANY {
then accept;
}
}
}
}
routing-instances {
PATH-1 {
instance-type forwarding;
routing-options {
static {
route 10.100.30.0/24 {
next-hop 10.100.254.2;
qualified-next-hop 10.10.10.1 {
preference 100;
}
}
}
}
}
}
New config snips for RTR-2:
routing-options {
interface-routes {
rib-group inet STAGING-RIB;
}
rib-groups {
STAGING-RIB {
import-rib [ inet.0 PATH-1.inet.0 ];
}
}
router-id 200.200.200.2;
autonomous-system 1;
}
firewall {
family inet {
filter FBF-TEST {
term TERM-1 {
from {
source-address {
10.100.190.0/24;
10.100.191.0/24;
}
}
then {
routing-instance PATH-1;
}
}
term PERMIT-ANY {
then accept;
}
}
}
}
routing-instances {
PATH-1 {
instance-type forwarding;
routing-options {
static {
route 10.100.30.0/24 {
next-hop 200.200.200.1;
qualified-next-hop 10.100.254.1 {
preference 100;
}
}
}
}
}
}
OSPF is a link state protocol that uses multicast. It sends Link State Advertisements (LSAs) that are flooded.
Every router builds a tree by running SPF where the router itself is the root of the tree. In OSPF we have transit networks and stub networks. Transit networks are networks that are used for transit to reach networks while stub networks are the endpoints or leaves as you described it.
If we are in the same area then the router LSA (type-1) is examined to find the destination. Here is a router-LSA to reach the network of R1 which has a RID of 1.1.1.1.
R2#sh ip ospf data router 1.1.1.1
OSPF Router with ID (2.2.2.2) (Process ID 1)
Router Link States (Area 0)
LS age: 256
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 1.1.1.1
Advertising Router: 1.1.1.1
LS Seq Number: 80000005
Checksum: 0x4B09
Length: 60
Number of Links: 3
Link connected to: a Stub Network
(Link ID) Network/subnet number: 1.1.1.1
(Link Data) Network Mask: 255.255.255.255
Number of TOS metrics: 0
TOS 0 Metrics: 1
Link connected to: a Transit Network
(Link ID) Designated Router address: 13.13.13.1
(Link Data) Router Interface address: 13.13.13.1
Number of TOS metrics: 0
TOS 0 Metrics: 10
Link connected to: a Transit Network
(Link ID) Designated Router address: 12.12.12.2
(Link Data) Router Interface address: 12.12.12.1
Number of TOS metrics: 0
TOS 0 Metrics: 10
R1 has a cost of 1 to this stub network. R2 can reach this network through the 12.12.12.0/24 transit network. So we need to add a cost of 10 which brings the total metric to 11.
R2#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 1", distance 110, metric 11, type intra area
Last update from 12.12.12.1 on FastEthernet0/0, 00:06:49 ago
Routing Descriptor Blocks:
* 12.12.12.1, from 1.1.1.1, 00:06:49 ago, via FastEthernet0/0
Route metric is 11, traffic share count is 1
This is an intra area route. For inter area routes OSPF actually behaves like a distance vector protocol because traffic is sent through the ABR. How can we identify an ABR?
R4#sh ip ospf data router 2.2.2.2
OSPF Router with ID (4.4.4.4) (Process ID 1)
Router Link States (Area 1)
Routing Bit Set on this LSA
LS age: 573
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 2.2.2.2
Advertising Router: 2.2.2.2
LS Seq Number: 80000002
Checksum: 0xCCB6
Length: 36
**Area Border Router**
Number of Links: 1
Link connected to: a Transit Network
(Link ID) Designated Router address: 24.24.24.2
(Link Data) Router Interface address: 24.24.24.2
Number of TOS metrics: 0
TOS 0 Metrics: 10
The B bit is set in the OSPF header which makes a router an ABR.
This can be seen in a packet capture.
To find the metric of an inter area route the metric of the ABR to the destination + the metric of the local route to the ABR is added.
R4#sh ip ospf border-routers
OSPF Process 1 internal Routing Table
Codes: i - Intra-area route, I - Inter-area route
i 2.2.2.2 [10] via 24.24.24.2, FastEthernet0/0, ABR, Area 1, SPF 4
i 3.3.3.3 [10] via 34.34.34.3, FastEthernet0/1, ABR, Area 1, SPF 4
R4#
Here the cost is 10 to reach the two ABRs. Because the cost was 11 from the ABR to the destination that should mean that R4 has a metric of 21.
R4#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 1", distance 110, metric 21, type inter area
Last update from 24.24.24.2 on FastEthernet0/0, 00:09:37 ago
Routing Descriptor Blocks:
* 34.34.34.3, from 3.3.3.3, 00:09:37 ago, via FastEthernet0/1
Route metric is 21, traffic share count is 1
24.24.24.2, from 2.2.2.2, 00:09:37 ago, via FastEthernet0/0
Route metric is 21, traffic share count is 1
Which it is. Because there are two ABRs here with the same cost both routes are installed into the RIB/FIB. If we increase the cost to one ABR then only one entry will be installed.
R4#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int f0/0
R4(config-if)#ip ospf cost 11
R4(config-if)#^Z
R4#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 1", distance 110, metric 21, type inter area
Last update from 34.34.34.3 on FastEthernet0/1, 00:10:58 ago
Routing Descriptor Blocks:
* 34.34.34.3, from 3.3.3.3, 00:10:58 ago, via FastEthernet0/1
Route metric is 21, traffic share count is 1
There really is no concept of AS in OSPF but you can originate a default route and then the best metric would win. I recommend that you read through RFC 2328 and OSPF: Anatomy of an Internet Routing Protocol if you want more understanding of OSPF.
Best Answer
Don't confuse the routing protocol tables with the routing table. Each routing protocol maintains its own set of tables which are not the same thing as the routing table. The routing table will contain the best routes from the routing protocol tables.
BGP and OSPF serve different purposes. OSPF will always be within a single AS. BGP is primarily to route between ASes (eBGP). BGP can be used within an AS (iBGP), but there are some limitations and rules for iBGP. For instance, iBGP peers cannot advertise routes learned from another iBGP peer, so iBGP must maintain a full mesh or use some sort of mitigation (route reflectors or confederations).
OSPF maintains a complete picture of the entire OSPF area in which it resides, and only that area, not necessarily an entire AS which may consist of multiple areas.
BGP will have entries for each neighbor, and the prefixes which each neighbor advertises to it, along with BGP attributes, which can take up considerable space.