Skip to content

Commit

Permalink
feat: Add ability to work with iptables using client (#1583)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii authored and ondrej-fabry committed Dec 9, 2019
1 parent c550b7b commit 6f6906d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clientv2/linux/data_change_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package linuxclient
import (
vpp_clientv2 "go.ligato.io/vpp-agent/v2/clientv2/vpp"
linux_interfaces "go.ligato.io/vpp-agent/v2/proto/ligato/linux/interfaces"
linux_iptables "go.ligato.io/vpp-agent/v2/proto/ligato/linux/iptables"
linux_l3 "go.ligato.io/vpp-agent/v2/proto/ligato/linux/l3"
vpp_abf "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/abf"
vpp_acl "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/acl"
Expand Down Expand Up @@ -62,6 +63,8 @@ type PutDSL interface {
LinuxArpEntry(val *linux_l3.ARPEntry) PutDSL
// LinuxRoute adds a request to crete or update Linux route
LinuxRoute(val *linux_l3.Route) PutDSL
// IptablesRuleChain adds request to create or update iptables rule chain.
IptablesRuleChain(val *linux_iptables.RuleChain) PutDSL

// VppInterface adds a request to create or update VPP network interface.
VppInterface(val *vpp_interfaces.Interface) PutDSL
Expand Down Expand Up @@ -135,6 +138,8 @@ type DeleteDSL interface {
LinuxArpEntry(ifaceName string, ipAddr string) DeleteDSL
// LinuxRoute adds a request to delete Linux route
LinuxRoute(dstAddr, outIfaceName string) DeleteDSL
// IptablesRuleChain adds request to delete iptables rule chain.
IptablesRuleChain(name string) DeleteDSL

// VppInterface adds a request to delete an existing VPP network interface.
VppInterface(ifaceName string) DeleteDSL
Expand Down
3 changes: 3 additions & 0 deletions clientv2/linux/data_resync_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package linuxclient
import (
vpp_clientv2 "go.ligato.io/vpp-agent/v2/clientv2/vpp"
linux_interfaces "go.ligato.io/vpp-agent/v2/proto/ligato/linux/interfaces"
linux_iptables "go.ligato.io/vpp-agent/v2/proto/ligato/linux/iptables"
linux_l3 "go.ligato.io/vpp-agent/v2/proto/ligato/linux/l3"
vpp_abf "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/abf"
vpp_acl "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/acl"
Expand All @@ -42,6 +43,8 @@ type DataResyncDSL interface {
LinuxArpEntry(arp *linux_l3.ARPEntry) DataResyncDSL
// LinuxInterface adds Linux route to the RESYNC request.
LinuxRoute(route *linux_l3.Route) DataResyncDSL
// IptablesRuleChain adds iptables rule chain to the RESYNC request.
IptablesRuleChain(val *linux_iptables.RuleChain) DataResyncDSL

// VppInterface adds VPP interface to the RESYNC request.
VppInterface(intf *vpp_interfaces.Interface) DataResyncDSL
Expand Down
13 changes: 13 additions & 0 deletions clientv2/linux/dbadapter/data_change_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"go.ligato.io/vpp-agent/v2/clientv2/vpp/dbadapter"
"go.ligato.io/vpp-agent/v2/pkg/models"
linux_interfaces "go.ligato.io/vpp-agent/v2/proto/ligato/linux/interfaces"
linux_iptables "go.ligato.io/vpp-agent/v2/proto/ligato/linux/iptables"
linux_l3 "go.ligato.io/vpp-agent/v2/proto/ligato/linux/l3"
abf "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/abf"
acl "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/acl"
Expand Down Expand Up @@ -97,6 +98,12 @@ func (dsl *PutDSL) LinuxRoute(val *linux_l3.Route) linuxclient.PutDSL {
return dsl
}

// IptablesRuleChain adds request to create or update iptables rule chain.
func (dsl *PutDSL) IptablesRuleChain(val *linux_iptables.RuleChain) linuxclient.PutDSL {
dsl.parent.txn.Put(linux_iptables.RuleChainKey(val.Name), val)
return dsl
}

// VppInterface adds a request to create or update VPP network interface.
func (dsl *PutDSL) VppInterface(val *interfaces.Interface) linuxclient.PutDSL {
dsl.vppPut.Interface(val)
Expand Down Expand Up @@ -279,6 +286,12 @@ func (dsl *DeleteDSL) LinuxRoute(dstAddr, outIfaceName string) linuxclient.Delet
return dsl
}

// IptablesRuleChain adds request to delete iptables rule chain.
func (dsl *DeleteDSL) IptablesRuleChain(name string) linuxclient.DeleteDSL {
dsl.parent.txn.Delete(linux_iptables.RuleChainKey(name))
return dsl
}

// VppInterface adds a request to delete an existing VPP network interface.
func (dsl *DeleteDSL) VppInterface(ifaceName string) linuxclient.DeleteDSL {
dsl.vppDelete.Interface(ifaceName)
Expand Down
10 changes: 10 additions & 0 deletions clientv2/linux/dbadapter/data_resync_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"go.ligato.io/vpp-agent/v2/clientv2/vpp/dbadapter"
"go.ligato.io/vpp-agent/v2/pkg/models"
linux_interfaces "go.ligato.io/vpp-agent/v2/proto/ligato/linux/interfaces"
linux_iptables "go.ligato.io/vpp-agent/v2/proto/ligato/linux/iptables"
linux_l3 "go.ligato.io/vpp-agent/v2/proto/ligato/linux/l3"
abf "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/abf"
acl "go.ligato.io/vpp-agent/v2/proto/ligato/vpp/acl"
Expand Down Expand Up @@ -81,6 +82,15 @@ func (dsl *DataResyncDSL) LinuxRoute(val *linux_l3.Route) linuxclient.DataResync
return dsl
}

// IptablesRuleChain adds iptables rule chain to the RESYNC request.
func (dsl *DataResyncDSL) IptablesRuleChain(val *linux_iptables.RuleChain) linuxclient.DataResyncDSL {
key := linux_iptables.RuleChainKey(val.Name)
dsl.txn.Put(key, val)
dsl.txnKeys = append(dsl.txnKeys, key)

return dsl
}

// VppInterface adds VPP interface to the RESYNC request.
func (dsl *DataResyncDSL) VppInterface(intf *interfaces.Interface) linuxclient.DataResyncDSL {
dsl.vppDataResync.Interface(intf)
Expand Down

0 comments on commit 6f6906d

Please sign in to comment.