@@ -767,6 +767,8 @@ func TestNATNodePort(t *testing.T) {
767
767
768
768
dumpCTMap (ctMap )
769
769
770
+ var vxlanSrcPort layers.UDPPort
771
+
770
772
skbMark = 0
771
773
// Another pkt arriving at node 1 - uses existing CT entries
772
774
runBpfTest (t , "calico_from_host_ep" , nil , func (bpfrun bpfProgRunFn ) {
@@ -783,9 +785,44 @@ func TestNATNodePort(t *testing.T) {
783
785
Expect (ipv4R .SrcIP .String ()).To (Equal (hostIP .String ()))
784
786
Expect (ipv4R .DstIP .String ()).To (Equal (node2ip .String ()))
785
787
788
+ udpL := pktR .Layer (layers .LayerTypeUDP )
789
+ Expect (udpL ).NotTo (BeNil ())
790
+ udpR := udpL .(* layers.UDP )
791
+
792
+ Expect (udpR .SrcPort ).To (Equal (udp .SrcPort ^ udp .DstPort ))
793
+ vxlanSrcPort = udpR .SrcPort
794
+
786
795
checkVxlanEncap (pktR , false , ipv4 , udp , payload )
787
796
})
788
797
798
+ skbMark = 0
799
+ // Another pkt iwith a different source port arriving at node 1
800
+ runBpfTest (t , "calico_from_host_ep" , nil , func (bpfrun bpfProgRunFn ) {
801
+
802
+ // Change the source port
803
+ pktBytes [14 + (20 + 8 )] = 0xde
804
+ pktBytes [14 + (20 + 8 )+ 1 ] = 0xad
805
+
806
+ res , err := bpfrun (pktBytes )
807
+ Expect (err ).NotTo (HaveOccurred ())
808
+ Expect (res .Retval ).To (Equal (resTC_ACT_UNSPEC ))
809
+
810
+ pktR := gopacket .NewPacket (res .dataOut , layers .LayerTypeEthernet , gopacket .Default )
811
+ fmt .Printf ("pktR = %+v\n " , pktR )
812
+
813
+ ipv4L := pktR .Layer (layers .LayerTypeIPv4 )
814
+ Expect (ipv4L ).NotTo (BeNil ())
815
+ ipv4R := ipv4L .(* layers.IPv4 )
816
+ Expect (ipv4R .SrcIP .String ()).To (Equal (hostIP .String ()))
817
+ Expect (ipv4R .DstIP .String ()).To (Equal (node2ip .String ()))
818
+
819
+ udpL := pktR .Layer (layers .LayerTypeUDP )
820
+ Expect (udpL ).NotTo (BeNil ())
821
+ udpR := udpL .(* layers.UDP )
822
+
823
+ Expect (udpR .SrcPort ).NotTo (Equal (vxlanSrcPort ))
824
+ })
825
+
789
826
expectMark (tcdefs .MarkSeenBypassForward )
790
827
791
828
/*
0 commit comments