Skip to content

Commit 497b175

Browse files
committed
Removed support for separate IPv6 topology
1 parent c87367f commit 497b175

File tree

112 files changed

+6843
-13120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+6843
-13120
lines changed

Changes

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
{{$NEXT}}
22

3-
- Fixed duplicate hosts from wrong IPv4 network in IPv6 aggregate.
3+
- Removed support for separate IPv6 topology in subdirectory 'ipv6/'.
4+
- Removed options '--ipv6', '-6'.
5+
- Removed support for NAT of IPv6 objects.
6+
After changing attributes of IPv6 addresses from 'ip' to 'ip6',
7+
supporting NAT for IPv6 would need to change NAT attributes
8+
to 'ip6', 'hidden6', 'identity6' as well.
9+
This seems to be superflous, since nobody uses NAT for IPv6.
10+
- Fixed duplicate hosts in print-group from wrong IPv4 network
11+
in IPv6 aggregate.
412
- Fixed panic in export-netspoc with rule from IPv4 network to
513
combined IPv4/v6 auto interface.
14+
- Changed 'format-netspoc' to print attributes "ip" and "ip6" in
15+
one line, if object has no more than 3 attributes.
616

717
6.076 2025-01-10 09:39:54+01:00 Europe/Berlin
818

go/pkg/addto/add-to-netspoc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func Main(d oslink.Data) int {
227227
dummyArgs := []string{fmt.Sprintf("--quiet=%v", *quiet)}
228228
cnf := conf.ConfigFromArgsAndFile(dummyArgs, path)
229229

230-
s, err := astset.Read(path, cnf.IPV6)
230+
s, err := astset.Read(path)
231231
if err != nil {
232232
fmt.Fprintf(d.Stderr, "Error: %s\n", err)
233233
return 1

go/pkg/api/modify.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func Main(d oslink.Data) int {
7878

7979
s := new(state)
8080
var err error
81-
s.State, err = astset.Read(netspocPath, cnf.IPV6)
81+
s.State, err = astset.Read(netspocPath)
8282
if err != nil {
8383
// Text of this error message is checked in git-worker1 of Netspoc-API.
8484
showErr("While reading netspoc files: %s", err)

go/pkg/api/path.go

+7-32
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ func (s *state) patch(j *job) error {
2222
Path string
2323
Value interface{}
2424
OkIfExists bool `json:"ok_if_exists"`
25-
IPV6 *bool
2625
}
2726
getParams(j, &p)
2827
c := change{val: p.Value, okIfExists: p.OkIfExists}
@@ -31,19 +30,13 @@ func (s *state) patch(j *job) error {
3130
if len(p.Path) == 0 {
3231
return fmt.Errorf("Invalid empty path")
3332
}
34-
var ipv6 bool
35-
if p.IPV6 != nil {
36-
ipv6 = *p.IPV6
37-
} else {
38-
ipv6 = s.IPV6
39-
}
4033
path := strings.Split(p.Path, ",")
41-
top, names, err := s.findToplevel(path, ipv6, c)
34+
top, names, err := s.findToplevel(path, c)
4235
if err != nil {
4336
return err
4437
}
4538
if top == nil {
46-
return s.addToplevel(path[0], ipv6, c)
39+
return s.addToplevel(path[0], c)
4740
}
4841
process := func() error {
4942
if len(names) == 0 {
@@ -99,9 +92,8 @@ func (s *state) patch(j *job) error {
9992
return err
10093
}
10194

102-
func (s *state) findToplevel(names []string, ipv6 bool, c change,
95+
func (s *state) findToplevel(names []string, c change,
10396
) (ast.Toplevel, []string, error) {
104-
10597
topName := names[0]
10698
var top ast.Toplevel
10799
if strings.HasPrefix(topName, "host:") {
@@ -139,21 +131,15 @@ func (s *state) findToplevel(names []string, ipv6 bool, c change,
139131
}
140132
return top, names, nil
141133
} else {
142-
isRouter := strings.HasPrefix(topName, "router:")
143134
names = names[1:]
144135
s.Modify(func(t ast.Toplevel) bool {
145-
if t.GetName() == topName && (!isRouter || t.GetIPV6() == ipv6) {
136+
if t.GetName() == topName {
146137
top = t
147138
return true // Mark as modified.
148139
}
149140
return false
150141
})
151142
if top == nil && len(names) > 0 {
152-
if isRouter {
153-
ipvx := getIPvX(ipv6)
154-
return nil, nil, fmt.Errorf(
155-
"Can't modify unknown %s '%s'", ipvx, topName)
156-
}
157143
return nil, nil, fmt.Errorf(
158144
"Can't modify unknown toplevel object '%s'", topName)
159145
}
@@ -389,7 +375,7 @@ func newAttribute(l *[]*ast.Attribute, name string, c change) error {
389375
return nil
390376
}
391377

392-
func (s *state) addToplevel(name string, ipv6 bool, c change) error {
378+
func (s *state) addToplevel(name string, c change) error {
393379
if c.method == "delete" {
394380
return fmt.Errorf("Can't %s unknown toplevel node '%s'", c.method, name)
395381
}
@@ -398,7 +384,7 @@ func (s *state) addToplevel(name string, ipv6 bool, c change) error {
398384
if err != nil {
399385
return err
400386
}
401-
s.AddTopLevel(a, ipv6)
387+
s.AddTopLevel(a)
402388
return nil
403389
}
404390

@@ -485,11 +471,7 @@ func (s *state) patchToplevel(n ast.Toplevel, c change) error {
485471
if c.okIfExists {
486472
return nil
487473
}
488-
ipvx := ""
489-
if r, ok := n.(*ast.Router); ok {
490-
ipvx = getIPvX(r.IPV6) + " "
491-
}
492-
return fmt.Errorf("%s'%s' already exists", ipvx, n.GetName())
474+
return fmt.Errorf("'%s' already exists", n.GetName())
493475
}
494476

495477
func getTopList(name string, m map[string]interface{}) (ast.Toplevel, error) {
@@ -730,10 +712,3 @@ func getElementList(val interface{}) ([]ast.Element, error) {
730712
}
731713
return elements, nil
732714
}
733-
734-
func getIPvX(v6 bool) string {
735-
if v6 {
736-
return "IPv6"
737-
}
738-
return "IPv4"
739-
}

go/pkg/ast/ast.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ type Toplevel interface {
3333
GetDescription() *Description
3434
FileName() string
3535
SetFileName(string)
36-
GetIPV6() bool
37-
SetIPV6()
3836
}
3937

4038
type ToplevelWithAttr interface {
@@ -121,7 +119,11 @@ type AggAuto struct {
121119
func (a AggAuto) String() string {
122120
var ext string
123121
if a.Net != "" {
124-
ext = "ip=" + a.Net + "&"
122+
attr := "ip"
123+
if a.IPV6 {
124+
attr += "6"
125+
}
126+
ext = attr + "=" + a.Net + "&"
125127
}
126128
return a.GetType() + ":[" + ext + joinElements(a.Elements, ",") + "]"
127129
}
@@ -187,16 +189,13 @@ type TopBase struct {
187189
Name string
188190
Description *Description
189191
fileName string
190-
IPV6 bool
191192
}
192193

193194
func (a TopBase) GetName() string { return a.Name }
194195
func (a *TopBase) SetName(n string) { a.Name = n }
195196
func (a TopBase) GetDescription() *Description { return a.Description }
196197
func (a TopBase) FileName() string { return a.fileName }
197198
func (a *TopBase) SetFileName(n string) { a.fileName = n }
198-
func (a TopBase) GetIPV6() bool { return a.IPV6 }
199-
func (a *TopBase) SetIPV6() { a.IPV6 = true }
200199

201200
type TopList struct {
202201
TopBase

go/pkg/astset/astset.go

+4-13
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,18 @@ type State struct {
1818
astFiles []*ast.File
1919
base string
2020
files []string
21-
IPV6 bool
2221
changed map[string]bool
2322
}
2423

25-
func Read(netspocBase string, v6 bool) (*State, error) {
24+
func Read(netspocBase string) (*State, error) {
2625
s := &State{
2726
base: netspocBase,
28-
IPV6: v6,
2927
changed: make(map[string]bool),
3028
}
31-
err := filetree.Walk(netspocBase, v6, func(input *filetree.Context) error {
29+
err := filetree.Walk(netspocBase, func(input *filetree.Context) error {
3230
source := []byte(input.Data)
3331
path := input.Path
34-
aF, err := parser.ParseFile(source, path, input.IPV6, parser.ParseComments)
32+
aF, err := parser.ParseFile(source, path, parser.ParseComments)
3533
if err != nil {
3634
return err
3735
}
@@ -128,7 +126,7 @@ func (s *State) FindToplevel(name string) ast.Toplevel {
128126
return result
129127
}
130128

131-
func (s *State) AddTopLevel(n ast.Toplevel, ipv6 bool) {
129+
func (s *State) AddTopLevel(n ast.Toplevel) {
132130
// Netspoc config is given in single file, add new node to this file.
133131
if len(s.files) == 1 && s.files[0] == s.base {
134132
s.CreateToplevel("", n)
@@ -155,13 +153,6 @@ func (s *State) AddTopLevel(n ast.Toplevel, ipv6 bool) {
155153
file = path.Join(file, "other")
156154
}
157155
}
158-
if ipv6 != s.IPV6 {
159-
if s.IPV6 {
160-
file = path.Join("ipv4", file)
161-
} else {
162-
file = path.Join("ipv6", file)
163-
}
164-
}
165156
s.CreateToplevel(file, n)
166157
}
167158

go/pkg/conf/GetArgs.go

-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ type Config struct {
7878
AutoDefaultRoute bool
7979
ConcurrencyPass1 int
8080
ConcurrencyPass2 int
81-
IPV6 bool `flag:"ipv6 6"`
8281
MaxErrors int `flag:"max_errors m"`
8382
Quiet bool `flag:"quiet q"`
8483
TimeStamps bool `flag:"time_stamps t"`
@@ -148,9 +147,6 @@ func defaultOptions(fs *flag.FlagSet) *Config {
148147
// which have no default route to the internet.
149148
AutoDefaultRoute: true,
150149

151-
// Use IPv4 version as default
152-
IPV6: false,
153-
154150
// Set value to >= 2 to start concurrent processing.
155151
ConcurrencyPass1: 1,
156152
ConcurrencyPass2: 1,

go/pkg/expand/expand-group.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func Main(d oslink.Data) int {
128128
// Change files.
129129
s := new(state)
130130
var err error
131-
s.State, err = astset.Read(path, cnf.IPV6)
131+
s.State, err = astset.Read(path)
132132
if err != nil {
133133
fmt.Fprintf(d.Stderr, "Error: %s\n", err)
134134
return 1

go/pkg/exportsyntax/export-netspoc-syntax.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"strings"
77

88
"github.com/hknutzen/Netspoc/go/pkg/ast"
9-
"github.com/hknutzen/Netspoc/go/pkg/conf"
109
"github.com/hknutzen/Netspoc/go/pkg/filetree"
1110
"github.com/hknutzen/Netspoc/go/pkg/oslink"
1211
"github.com/hknutzen/Netspoc/go/pkg/parser"
@@ -41,13 +40,12 @@ func Main(d oslink.Data) int {
4140
filter[name] = true
4241
}
4342
path := args[0]
44-
cnf := conf.ConfigFromArgsAndFile(nil, path)
4543
// Group definitions by type.
4644
definitions := make(map[string][]jsonMap)
47-
err := filetree.Walk(path, cnf.IPV6, func(input *filetree.Context) error {
45+
err := filetree.Walk(path, func(input *filetree.Context) error {
4846
source := []byte(input.Data)
4947
path := input.Path
50-
aF, err := parser.ParseFile(source, path, input.IPV6, 0)
48+
aF, err := parser.ParseFile(source, path, 0)
5149
if err != nil {
5250
return err
5351
}
@@ -79,9 +77,6 @@ func convertToMap(n ast.Toplevel) jsonMap {
7977
if d := n.GetDescription(); d != nil {
8078
m["description"] = d.Text
8179
}
82-
if v := n.GetIPV6(); v {
83-
m["ipv6"] = v
84-
}
8580
if x, ok := n.(ast.ToplevelWithAttr); ok {
8681
mapAttributes(m, x.GetAttributes())
8782
}

go/pkg/filetree/walk.go

+8-16
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ import (
1111
type Context struct {
1212
Path string
1313
Data string
14-
IPV6 bool
1514
}
1615
type parser func(*Context) error
1716

1817
// Read input from file and process it by function which is given as argument.
19-
func processFile(fname string, v6 bool, fn parser) error {
20-
input := &Context{Path: fname, IPV6: v6}
18+
func processFile(fname string, fn parser) error {
19+
input := &Context{Path: fname}
2120
content, err := os.ReadFile(fname)
2221
if err != nil {
2322
return err
@@ -26,9 +25,9 @@ func processFile(fname string, v6 bool, fn parser) error {
2625
return fn(input)
2726
}
2827

29-
func Walk(fname string, v6 bool, fn parser) error {
30-
var walk func(string, bool, bool) error
31-
walk = func(fname string, v6, toplevel bool) error {
28+
func Walk(fname string, fn parser) error {
29+
var walk func(string, bool) error
30+
walk = func(fname string, toplevel bool) error {
3231
if !toplevel {
3332
base := path.Base(fname)
3433

@@ -37,16 +36,9 @@ func Walk(fname string, v6 bool, fn parser) error {
3736
return nil
3837
}
3938

40-
// Handle ipv6 / ipv4 subdirectory or file.
41-
switch base {
42-
case "ipv4":
43-
v6 = false
44-
case "ipv6":
45-
v6 = true
46-
}
4739
}
4840
if !fileop.IsDir(fname) {
49-
return processFile(fname, v6, fn)
41+
return processFile(fname, fn)
5042
}
5143
files, err := os.ReadDir(fname)
5244
if err != nil {
@@ -60,12 +52,12 @@ func Walk(fname string, v6 bool, fn parser) error {
6052
continue
6153
}
6254
name := filepath.Join(fname, base)
63-
if err := walk(name, v6, false); err != nil {
55+
if err := walk(name, false); err != nil {
6456
return err
6557
}
6658
}
6759
return nil
6860
}
6961
toplevel := true
70-
return walk(fname, v6, toplevel)
62+
return walk(fname, toplevel)
7163
}

go/pkg/format/format-netspoc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ func Main(d oslink.Data) int {
4646
cnf := conf.ConfigFromArgsAndFile(dummyArgs, path)
4747

4848
// Process each file.
49-
err := filetree.Walk(path, cnf.IPV6, func(input *filetree.Context) error {
49+
err := filetree.Walk(path, func(input *filetree.Context) error {
5050
source := []byte(input.Data)
5151
path := input.Path
52-
aF, err := parser.ParseFile(source, path, input.IPV6, parser.ParseComments)
52+
aF, err := parser.ParseFile(source, path, parser.ParseComments)
5353
if err != nil {
5454
return err
5555
}

0 commit comments

Comments
 (0)