Repository: scionproto/scion
Pull request #3664 (2020-02-13 14:58:32)

braccept: expired revocation on interface not owned


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3664)
<!-- Reviewable:end -->



Patch:
diff --git a/go/border/braccept/parser/revinfo.go b/go/border/braccept/parser/revinfo.go
index a22afa83d..49fe71fc9 100644
--- a/go/border/braccept/parser/revinfo.go
+++ b/go/border/braccept/parser/revinfo.go
@@ -17,7 +17,6 @@ package parser
 import (
 	"fmt"
 	"strings"
-	"time"
 
 	"github.com/google/gopacket"
 
@@ -120,11 +119,7 @@ func (i *RevInfo) updateFields(kvs propMap) {
 			i.RawIsdas = ia.IAInt()
 		case "TS":
 			if v != "now" {
-				t, err := time.Parse(common.TimeFmt, v)
-				if err != nil {
-					panic(err)
-				}
-				i.RawTimestamp = uint32(t.Unix())
+				i.RawTimestamp = uint32(StrToInt(v))
 			} else {
 				i.RawTimestamp = shared.TsNow32
 			}
diff --git a/go/border/rpkt/path.go b/go/border/rpkt/path.go
index 86dad1683..a4744a745 100644
--- a/go/border/rpkt/path.go
+++ b/go/border/rpkt/path.go
@@ -84,7 +84,8 @@ func (rp *RtrPkt) validateLocalIF(ifid *common.IFIDType) error {
 	if ifid == nil {
 		return serrors.New("validateLocalIF: Interface is nil")
 	}
-	if _, ok := rp.Ctx.Conf.Topo.IFInfoMap()[*ifid]; !ok {
+	intf, ok := rp.Ctx.Conf.Topo.IFInfoMap()[*ifid]
+	if !ok {
 		// No such interface.
 		return common.NewBasicError(
 			"Unknown IF",
@@ -123,7 +124,6 @@ func (rp *RtrPkt) validateLocalIF(ifid *common.IFIDType) error {
 		}
 		// If the BR does not have a revocation for the current epoch, it considers
 		// the interface as active until it receives a new revocation.
-		intf := rp.Ctx.Conf.BR.IFs[*ifid]
 		newState := ifstate.NewInfo(*ifid, intf.IA, true, nil, nil)
 		ifstate.UpdateIfNew(*ifid, state, newState)
 		return nil


Test patch:
diff --git a/go/border/braccept/br_tests.go b/go/border/braccept/br_tests.go
index 4d4ff64ab..97d0313a6 100644
--- a/go/border/braccept/br_tests.go
+++ b/go/border/braccept/br_tests.go
@@ -110,6 +110,7 @@ func br_parent() int {
 
 	failures += revocation_owned_parent()
 	failures += revocation_not_owned_child_link()
+	failures += revocation_expired_not_owned_child_link()
 
 	failures += ohp_parent_to_internal_bs()
 	failures += ohp_udp_parent_to_internal_bs()
diff --git a/go/border/braccept/revocation_tests.go b/go/border/braccept/revocation_tests.go
index eadbdecff..e07a078b9 100644
--- a/go/border/braccept/revocation_tests.go
+++ b/go/border/braccept/revocation_tests.go
@@ -16,6 +16,7 @@ package main
 
 import (
 	"fmt"
+	"time"
 
 	"github.com/scionproto/scion/go/border/braccept/shared"
 )
@@ -505,3 +506,57 @@ func revocation_not_owned_child_link() int {
 
 	return ret
 }
+
+func revocation_expired_not_owned_child_link() int {
+
+	shared.UpdateNow()
+
+	ifStateDown := AllocatePacket()
+	ifStateDown.ParsePacket(fmt.Sprintf(`
+		Ethernet: SrcMAC=f0:0d:ca:fe:be:ef DstMAC=f0:0d:ca:fe:00:01 EthernetType=IPv4
+		IP4: Src=192.168.0.61 Dst=192.168.0.11 NextHdr=UDP Flags=DF
+		UDP: Src=20006 Dst=30041
+		SCION: NextHdr=UDP SrcType=IPv4 DstType=IPv4
+			ADDR: SrcIA=1-ff00:0:1 Src=192.168.0.61 DstIA=1-ff00:0:1 Dst=192.168.0.101
+		UDP_1: Src=20006 Dst=20001
+		IFStateInfo: IfID=181 Active=false
+			SignedRevInfo: IfID=181 IA=1-ff00:0:1 Link=child TS=%d TTL=10
+	`, time.Now().Add(-9*time.Second).Unix()))
+	ifStateDown.SetDev("veth_int")
+	ifStateDown.SetChecksum("UDP", "IP4")
+	ifStateDown.SetChecksum("UDP_1", "SCION")
+
+	pkt0 := AllocatePacket()
+	pkt0.ParsePacket(`
+		Ethernet: SrcMAC=f0:0d:ca:fe:be:ef DstMAC=f0:0d:ca:fe:00:13 EthernetType=IPv4
+		IP4: Src=192.168.13.3 Dst=192.168.13.2 NextHdr=UDP Flags=DF
+		UDP: Src=40000 Dst=50000
+		SCION: NextHdr=UDP CurrInfoF=4 CurrHopF=6 SrcType=IPv4 DstType=IPv4
+			ADDR: SrcIA=1-ff00:0:3 Src=172.16.3.1 DstIA=1-ff00:0:8 Dst=172.16.8.1
+			IF_1: ISD=1 Hops=3 Flags=ConsDir
+				HF_1: ConsIngress=0   ConsEgress=311
+				HF_2: ConsIngress=131 ConsEgress=181
+				HF_3: ConsIngress=811 ConsEgress=0
+		UDP_1: Src=40111 Dst=40222
+	`)
+	pkt0.SetDev("veth_131")
+	pkt0.SetChecksum("UDP", "IP4")
+	pkt0.SetChecksum("UDP_1", "SCION")
+	pkt0.GenerateMac("SCION", "IF_1", "HF_2", "HF_1")
+
+	pkt1 := pkt0.CloneAndUpdate(`
+		Ethernet: SrcMAC=f0:0d:ca:fe:00:01 DstMAC=f0:0d:ca:fe:be:ef
+		IP4: Src=192.168.0.11 Dst=192.168.0.13 Checksum=0
+		UDP: Src=30001 Dst=30003
+	`)
+	pkt1.SetDev("veth_int")
+	pkt1.SetChecksum("UDP", "IP4")
+
+	// Send/Expect packets
+	SendPackets(ifStateDown)
+	Sleep("1000ms")
+
+	SendPackets(pkt0)
+
+	return ExpectedPackets("expired revoked child (not owned) interface", defaultTimeout, pkt1)
+}