OpenBMP / obmp-psql

New OpenBMP PostgreSQL consumer and database
BSD 3-Clause "New" or "Revised" License
6 stars 9 forks source link

L3VPN Prefix History marks all AdjRIB-IN/OUT and Pre/Post-policy routes as Pre-Policy + RIB-IN only #10

Open v1shnya opened 1 year ago

v1shnya commented 1 year ago

Base table in the file "10_l3vpn.sql"

CREATE TABLE l3vpn_rib (
.....
                           isPrePolicy             boolean             NOT NULL DEFAULT true,
                           isAdjRibIn              boolean             NOT NULL DEFAULT true,
);

Dependent table (correct)

CREATE TABLE l3vpn_rib_log (
.....
                               isPrePolicy             boolean             NOT NULL DEFAULT true,
                               isAdjRibIn              boolean             NOT NULL DEFAULT true,
) TABLESPACE timeseries;

PostgreSQL function for the insertion into l3vpn_rib_log misses new.isPrePolicy and new.isAdjRibIn values!

CREATE OR REPLACE FUNCTION t_l3vpn_rib_update()
    RETURNS trigger AS $$
BEGIN
    IF (new.isWithdrawn) THEN
        INSERT INTO l3vpn_rib_log (isWithdrawn,prefix,prefix_len,base_attr_hash_id,peer_hash_id,origin_as,timestamp,
                                   rd,ext_community_list)
        VALUES (true,new.prefix,new.prefix_len,old.base_attr_hash_id,new.peer_hash_id,
                old.origin_as,new.timestamp,old.rd,old.ext_community_list);
    ELSE
        INSERT INTO l3vpn_rib_log (isWithdrawn,prefix,prefix_len,base_attr_hash_id,peer_hash_id,origin_as,timestamp,
                                   rd,ext_community_list)
        VALUES (false,new.prefix,new.prefix_len,new.base_attr_hash_id,new.peer_hash_id,
                new.origin_as,new.timestamp,new.rd,new.ext_community_list);
    END IF;

    RETURN NEW;
END;
$$ LANGUAGE plpgsql;