Skip to content

Commit c2089eb

Browse files
authored
Merge pull request FDio#27 from TetsuyaMurakami/ietf105-hackathon
This commit fix FDio#20, fix FDio#25 and fix FDio#26
2 parents a7cf6c6 + 6086397 commit c2089eb

File tree

7 files changed

+153
-46
lines changed

7 files changed

+153
-46
lines changed

extras/ietf105/Dockerfile.j2

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,17 @@ COPY . / {{vpp_path}}/
2525
WORKDIR {{vpp_path}}
2626

2727
RUN set -eux; \
28-
make wipe
29-
30-
RUN set -eux; \
28+
make wipe; \
3129
export UNATTENDED=y; \
3230
make install-dep; \
33-
rm -rf /var/lib/apt/lists/*
34-
35-
RUN set -eux; \
36-
export UNATTENDED=y; \
31+
rm -rf /var/lib/apt/lists/* ; \
3732
make build; \
3833
make pkg-deb; \
3934
rm -rf .ccache; \
40-
find . -type f -name '*.o' -delete
41-
42-
WORKDIR {{vpp_path}}/build-root
43-
44-
RUN set -eux; \
35+
find . -type f -name '*.o' -delete ; \
36+
cd {{vpp_path}}/build-root; \
4537
rm vpp-api-python_*.deb; \
46-
dpkg -i *.deb
47-
48-
RUN set -euex; \
38+
dpkg -i *.deb ; \
4939
cp {{vpp_path}}/startup.conf /etc/startup.conf; \
5040
rm -rf {{vpp_path}}
5141

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
FROM ubuntu:18.04
3+
4+
RUN set -eux; \
5+
apt-get update; \
6+
apt-get install -y --no-install-recommends \
7+
inetutils-traceroute \
8+
ca-certificates \
9+
build-essential \
10+
git gdb sudo \
11+
iputils-ping \
12+
net-tools \
13+
iproute2 \
14+
tcpdump \
15+
python3-cffi \
16+
netcat; \
17+
rm -rf /var/lib/apt/lists/*; \
18+
mv /usr/sbin/tcpdump /usr/bin/tcpdump
19+
20+
WORKDIR /tmp
21+
22+
RUN set -eux; \
23+
git clone -b ietf105-hackathon https://github.com/filvarga/srv6-mobile.git; \
24+
cd /tmp/srv6-mobile; \
25+
make wipe; \
26+
export UNATTENDED=y; \
27+
make install-dep; \
28+
rm -rf /var/lib/apt/lists/* ; \
29+
make build; \
30+
make pkg-deb; \
31+
rm -rf .ccache; \
32+
find . -type f -name '*.o' -delete ; \
33+
cd /tmp/srv6-mobile/build-root; \
34+
rm vpp-api-python_*.deb; \
35+
dpkg -i *.deb ; \
36+
cp /tmp/srv6-mobile/extras/ietf105/startup.conf.j2 /etc/startup.conf; \
37+
rm -rf /tmp/srv6-mobile
38+
39+
WORKDIR /
40+
41+
CMD vpp -c /etc/startup.conf
42+

extras/ietf105/runner.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ def build(self, path, vpp_path):
225225
tag=self.image, rm=True)
226226
return ref
227227

228+
def release(self, path, vpp_path):
229+
env = Environment(
230+
loader=FileSystemLoader(path),
231+
trim_blocks=True)
232+
233+
self.tmp_render(join(vpp_path, "Dockerfile"),
234+
env.get_template("Dockerfile.j2.release"),
235+
{'vpp_path': vpp_path})
236+
237+
ref, _ = self.client.images.build(path=vpp_path,
238+
tag=self.image, rm=True)
239+
return ref
240+
228241
def new(self, name):
229242
return Container.new(self.client, self.image, name)
230243

@@ -519,14 +532,14 @@ def test_tmap(self):
519532
local_mac="aa:bb:cc:dd:ee:11", remote_mac="aa:bb:cc:dd:ee:22")
520533

521534
c1.vppctl_exec("set sr encaps source addr A1::1")
522-
c1.vppctl_exec("sr policy add bsid D1:: next D2:: next D3:: gtp4_removal sr_prefix D4::/32 local_prefix C1::/64")
535+
c1.vppctl_exec("sr policy add bsid D1:: next D2:: next D3:: gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64")
523536
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D1::")
524537

525538
c2.vppctl_exec("sr localsid address D2:: behavior end")
526539

527540
c3.vppctl_exec("sr localsid address D3:: behavior end")
528541

529-
c4.vppctl_exec("sr localsid prefix D4::/32 behavior end.m.gtp4.e C1::/64")
542+
c4.vppctl_exec("sr localsid prefix D4::/32 behavior end.m.gtp4.e v4src_position 64")
530543

531544
c2.set_ipv6_route("eth2", "A2::2", "D3::/128")
532545
c2.set_ipv6_route("eth1", "A1::1", "C::/120")
@@ -580,14 +593,14 @@ def test_tmap_ipv6(self):
580593
local_mac="aa:bb:cc:dd:ee:11", remote_mac="aa:bb:cc:dd:ee:22")
581594

582595
c1.vppctl_exec("set sr encaps source addr A1::1")
583-
c1.vppctl_exec("sr policy add bsid D1:: next D2:: next D3:: gtp4_removal sr_prefix D4::/32 local_prefix C1::/64")
596+
c1.vppctl_exec("sr policy add bsid D1:: next D2:: next D3:: gtp4_removal sr_prefix D4::/32 v6src_prefix C1::/64")
584597
c1.vppctl_exec("sr steer l3 172.20.0.1/32 via bsid D1::")
585598

586599
c2.vppctl_exec("sr localsid address D2:: behavior end")
587600

588601
c3.vppctl_exec("sr localsid address D3:: behavior end")
589602

590-
c4.vppctl_exec("sr localsid prefix D4::/32 behavior end.m.gtp4.e C1::/64")
603+
c4.vppctl_exec("sr localsid prefix D4::/32 behavior end.m.gtp4.e v4src_position 64")
591604

592605
c2.set_ipv6_route("eth2", "A2::2", "D3::/128")
593606
c2.set_ipv6_route("eth1", "A1::1", "C::/120")
@@ -914,6 +927,9 @@ def build_image(self):
914927
# TODO: optimize build process for speed and image size
915928
self.containers.build(self.path, self.vpp_path)
916929

930+
def release_image(self):
931+
self.containers.release(self.path, self.vpp_path)
932+
917933
def vppctl(self, index, command=None):
918934
if index >= len(self.instance_names):
919935
return
@@ -943,7 +959,7 @@ def get_args():
943959
help="Infrastructure related commands.")
944960

945961
p1.add_argument("op", choices=[
946-
'stop', 'start', 'status', 'restart', 'build'])
962+
'stop', 'start', 'status', 'restart', 'build', 'release'])
947963

948964
p1.add_argument("--prefix")
949965
p1.add_argument("--image")
@@ -984,6 +1000,8 @@ def main(op=None, image=None, prefix=None, verbose=None, index=None, command=Non
9841000
try:
9851001
if op == 'build':
9861002
program.build_image()
1003+
elif op == 'release':
1004+
program.release_image()
9871005
elif op == 'stop':
9881006
program.stop_containers()
9891007
elif op == 'start':

src/plugins/srv6-mobile/gtp4_e.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ clb_format_srv6_end_m_gtp4_e (u8 * s, va_list * args)
6969

7070
s = format (s, "SRv6 End gtp4.e\n\t");
7171

72-
s = format (s, "Local Prefix: %U/%d\n", format_ip6_address, &ls_mem->local_prefix, ls_mem->local_prefixlen);
72+
s = format (s, "IPv4 address position: %d\n", ls_mem->local_prefixlen);
7373

7474
return s;
7575
}
@@ -79,18 +79,16 @@ clb_unformat_srv6_end_m_gtp4_e (unformat_input_t * input, va_list * args)
7979
{
8080
void **plugin_mem_p = va_arg (*args, void **);
8181
srv6_end_gtp4_param_t *ls_mem;
82-
ip6_address_t local_prefix;
8382
u32 local_prefixlen;
8483

85-
if (!unformat (input, "end.m.gtp4.e %U/%d",
86-
unformat_ip6_address, &local_prefix, &local_prefixlen))
84+
if (!unformat (input, "end.m.gtp4.e v4src_position %d",
85+
&local_prefixlen))
8786
return 0;
8887

8988
ls_mem = clib_mem_alloc_aligned_at_offset (sizeof *ls_mem, 0, 0, 1);
9089
clib_memset (ls_mem, 0, sizeof *ls_mem);
9190
*plugin_mem_p = ls_mem;
9291

93-
ls_mem->local_prefix = local_prefix;
9492
ls_mem->local_prefixlen = local_prefixlen;
9593

9694
return 1;

src/plugins/srv6-mobile/mobile.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ typedef struct srv6_end_gtp6_param_s
3636

3737
typedef struct srv6_end_gtp4_param_s
3838
{
39-
ip6_address_t local_prefix;
4039
u32 local_prefixlen;
4140
} srv6_end_gtp4_param_t;
4241

src/plugins/srv6-mobile/node.c

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ typedef enum
150150
SRV6_END_M_GTP6_D_DI_N_NEXT,
151151
} srv6_end_m_gtp6_d_di_next_t;
152152

153+
static inline u16
154+
hash_uword_to_u16 (uword *key)
155+
{
156+
u16 *val;
157+
val = (u16 *)key;
158+
#if uword_bits == 64
159+
return val[0] ^ val[1] ^ val[3] ^ val[4];
160+
#else
161+
return val[0] ^ val[1];
162+
#endif
163+
}
164+
153165
// Function for SRv6 GTP4.E function.
154166
VLIB_NODE_FN (srv6_end_m_gtp4_e) (vlib_main_t * vm,
155167
vlib_node_runtime_t * node,
@@ -219,6 +231,14 @@ VLIB_NODE_FN (srv6_end_m_gtp4_e) (vlib_main_t * vm,
219231
}
220232
else
221233
{
234+
u32 teid;
235+
u8 *teid8p = (u8 *)&teid;
236+
u32 index;
237+
u32 offset, shift;
238+
uword key;
239+
u16 port;
240+
void *p;
241+
222242
// we need to be sure there is enough space before
223243
// ip6srv0 header, there is some extra space
224244
// in the pre_data area for this kind of
@@ -237,6 +257,8 @@ VLIB_NODE_FN (srv6_end_m_gtp4_e) (vlib_main_t * vm,
237257
}
238258

239259
// get length of encapsulated IPv6 packet (the remaining part)
260+
p = vlib_buffer_get_current (b0);
261+
240262
len0 = vlib_buffer_length_in_chain (vm, b0);
241263

242264
// jump back to data[0] or pre_data if required
@@ -246,11 +268,6 @@ VLIB_NODE_FN (srv6_end_m_gtp4_e) (vlib_main_t * vm,
246268

247269
clib_memcpy (hdr0, &sm->cache_hdr, sizeof (ip4_gtpu_header_t));
248270

249-
u32 teid;
250-
u8 *teid8p = (u8 *)&teid;
251-
u32 index;
252-
u32 offset, shift;
253-
254271
offset = ls0->localsid_len / 8;
255272
shift = ls0->localsid_len % 8;
256273

@@ -283,32 +300,43 @@ VLIB_NODE_FN (srv6_end_m_gtp4_e) (vlib_main_t * vm,
283300
shift = ls_param->local_prefixlen % 8;
284301

285302
if (PREDICT_TRUE(shift == 0)) {
303+
#if 0
286304
u8 *pp;
287-
288305
pp = (u8 *) &hdr0->udp.src_port;
306+
#endif
289307

290308
for (index = 0; index < 4; index ++) {
291309
hdr0->ip4.src_address.as_u8[index] = src0.as_u8[offset + index];
292310
}
293311

312+
#if 0
294313
for (index = 0; index < 2; index++) {
295314
pp[index] = src0.as_u8[offset + 4 + index];
296315
}
316+
#endif
297317
} else {
318+
#if 0
298319
u8 *pp;
299-
300320
pp = (u8 *) &hdr0->udp.src_port;
321+
#endif
322+
301323
for (index = 0; index < 4; index ++) {
302324
hdr0->ip4.src_address.as_u8[index] = src0.as_u8[offset + index] << shift;
303325
hdr0->ip4.src_address.as_u8[index] |= src0.as_u8[offset + index + 1] >> (8 - shift);
304326
}
305327

328+
#if 0
306329
for (index = 0; index < 2; index++) {
307330
pp[index] = src0.as_u8[offset + index + 4] << shift;
308331
pp[index] |= src0.as_u8[offset + index + 5] >> (8 - shift);
309332
}
333+
#endif
310334
}
311335

336+
key = hash_memory(p, len0, 0);
337+
port = hash_uword_to_u16(&key);
338+
hdr0->udp.src_port = port;
339+
312340
hdr0->udp.length = clib_host_to_net_u16 (len0 +
313341
sizeof (udp_header_t) + sizeof (gtpu_header_t));
314342

@@ -372,18 +400,6 @@ VLIB_REGISTER_NODE (srv6_end_m_gtp4_e) = {
372400
},
373401
};
374402

375-
static inline u16
376-
hash_uword_to_u16 (uword *key)
377-
{
378-
u16 *val;
379-
val = (u16 *)key;
380-
#if uword_bits == 64
381-
return val[0] ^ val[1] ^ val[3] ^ val[4];
382-
#else
383-
return val[0] ^ val[1];
384-
#endif
385-
}
386-
387403
// Function for SRv6 GTP6.E function
388404
VLIB_NODE_FN (srv6_end_m_gtp6_e) (vlib_main_t * vm,
389405
vlib_node_runtime_t * node,

0 commit comments

Comments
 (0)