@@ -2377,6 +2377,65 @@ func (c LegacyClient) CreateSgDenyAllACL() error {
2377
2377
return nil
2378
2378
}
2379
2379
2380
+ func (c LegacyClient ) CreateSgBaseEgressACL (sgName string ) error {
2381
+ portGroupName := GetSgPortGroupName (sgName )
2382
+ klog .Infof ("add base egress acl, sg: %s" , portGroupName )
2383
+ // allow arp
2384
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclEgressDirection ), util .SecurityGroupBasePriority ,
2385
+ fmt .Sprintf ("outport==@%s && arp" , portGroupName ), "allow-related" ); err != nil {
2386
+ return err
2387
+ }
2388
+
2389
+ // icmpv6
2390
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclEgressDirection ), util .SecurityGroupBasePriority ,
2391
+ fmt .Sprintf ("outport==@%s && icmp6.type=={130, 133, 135, 136} && icmp6.code == 0 && ip.ttl == 255" , portGroupName ), "allow-related" ); err != nil {
2392
+ return err
2393
+ }
2394
+
2395
+ // dhcpv4 res
2396
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclEgressDirection ), util .SecurityGroupBasePriority ,
2397
+ fmt .Sprintf ("outport==@%s && udp.src==68 && udp.dst==67 && ip4" , portGroupName ), "allow-related" ); err != nil {
2398
+ return err
2399
+ }
2400
+
2401
+ // dhcpv6 res
2402
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclEgressDirection ), util .SecurityGroupBasePriority ,
2403
+ fmt .Sprintf ("outport==@%s && udp.src==546 && udp.dst==547 && ip6" , portGroupName ), "allow-related" ); err != nil {
2404
+ return err
2405
+ }
2406
+ return nil
2407
+ }
2408
+
2409
+ func (c LegacyClient ) CreateSgBaseIngressACL (sgName string ) error {
2410
+ portGroupName := GetSgPortGroupName (sgName )
2411
+ klog .Infof ("add base ingress acl, sg: %s" , portGroupName )
2412
+ // allow arp
2413
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclIngressDirection ), util .SecurityGroupBasePriority ,
2414
+ fmt .Sprintf ("inport==@%s && arp" , portGroupName ), "allow-related" ); err != nil {
2415
+ return err
2416
+ }
2417
+
2418
+ // icmpv6
2419
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclIngressDirection ), util .SecurityGroupBasePriority ,
2420
+ fmt .Sprintf ("inport==@%s && icmp6.type=={130, 134, 135, 136} && icmp6.code == 0 && ip.ttl == 255" , portGroupName ), "allow-related" ); err != nil {
2421
+ return err
2422
+ }
2423
+
2424
+ // dhcpv4 offer
2425
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclIngressDirection ), util .SecurityGroupBasePriority ,
2426
+ fmt .Sprintf ("inport==@%s && udp.src==67 && udp.dst==68 && ip4" , portGroupName ), "allow-related" ); err != nil {
2427
+ return err
2428
+ }
2429
+
2430
+ // dhcpv6 offer
2431
+ if _ , err := c .ovnNbCommand (MayExist , "--type=port-group" , "acl-add" , portGroupName , string (SgAclIngressDirection ), util .SecurityGroupBasePriority ,
2432
+ fmt .Sprintf ("inport==@%s && udp.src==547 && udp.dst==546 && ip6" , portGroupName ), "allow-related" ); err != nil {
2433
+ return err
2434
+ }
2435
+
2436
+ return nil
2437
+ }
2438
+
2380
2439
func (c LegacyClient ) UpdateSgACL (sg * kubeovnv1.SecurityGroup , direction AclDirection ) error {
2381
2440
sgPortGroupName := GetSgPortGroupName (sg .Name )
2382
2441
// clear acl
0 commit comments