Skip to contentSkip to conversation

tftp: fake support for netascii protocol

GIT PULL In review Samuel Thibault 9 participants 20 messages Nov 18, 2016 – Nov 23, 2016

lore
Share & tools
lore
#0 lore raw

The following changes since commit b0bcc86d2a87456f5a276f941dc775b265b309cf:

Update version for v2.8.0-rc0 release (2016-11-15 20:55:12 +0000)

are available in the git repository at:

http://people.debian.org/~sthibault/qemu.git tags/samuel-thibault

for you to fetch changes up to 43fccf87c92a6a88a7294597b719f17fd1b41d3d:

tftp: fake support for netascii protocol (2016-11-18 18:49:02 +0100)

----------------------------------------------------------------
slirp updates

----------------------------------------------------------------
Vincent Bernat (1):
tftp: fake support for netascii protocol

 slirp/tftp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
#1 lore raw

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly.

---
 slirp/tftp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
slirp/tftp.c +5 -3
index c185906..ab1c05d 100644
@@ -326,13 +326,15 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,
     return;
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      k += 9;
+  } else {
       tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
       return;
   }
 
-  k += 6; /* skipping octet */
-
   /* do sanity checks on the filename */
   if (!strncmp(req_fname, "../", 3) ||
       req_fname[strlen(req_fname) - 1] == '/' ||
Signature · 1 line
2.10.2
#2 lore raw
Your series seems to have some coding style problems. See output below for more information:

Hi,

Your series seems to have some coding style problems. See output below for more information:

Subject: [Qemu-devel] [PULL] tftp: fake support for netascii protocol
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
01931bf tftp: fake support for netascii protocol

=== OUTPUT BEGIN ===
Checking PATCH 1/1: tftp: fake support for netascii protocol...
ERROR: suspect code indent for conditional statements (2, 6) #27: FILE: slirp/tftp.c:329:
+ if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+ k += 6;

ERROR: suspect code indent for conditional statements (2, 6) #29: FILE: slirp/tftp.c:331:
+ } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+ k += 9;

total: 2 errors, 0 warnings, 18 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#3 lore raw
In reply to Samuel Thibault
Quoted 7 lines · Samuel Thibault

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex.

That sounds somewhat wrong to me. QEMU now seems to support a transfer mode that is not really implemented. I think you should at least issue a qemu_log_mask(LOG_UNIMP, "...") call in that case.

Thomas

PS: As far as I know, this month, PULL requests should be CC:ed to Stefan, not Peter, since Peter is away.

#4 lore raw

❦ 19 novembre 2016 08:32 +0100, Thomas Huth <[email protected]> :

Quoted 8 lines
Quoted 5 lines

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex.

That sounds somewhat wrong to me. QEMU now seems to support a transfer mode that is not really implemented.

On the other hand, the current implementation may not RFC compliant as the three modes (netascii, octet, mail) are not supported (but the RFC predates the usage of MAY/SHOULD/MUST, so it's unclear for me).

I have tried to add proper support, but this is more invasive as we cannot just seek in the file to get each block. However, this is something that I can do if compliance is important for QEMU.

Quoted 2 lines

I think you should at least issue a qemu_log_mask(LOG_UNIMP, "...") call in that case.

I can do that if needed.

Signature · 2 lines
10.0 times 0.1 is hardly ever 1.0.
            - The Elements of Programming Style (Kernighan & Plauger)
#5 lore raw
Quoted 15 lines · Vincent Bernat, on Sat 19 Nov 2016 09:03:08 +0100, wrote:

❦ 19 novembre 2016 08:32 +0100, Thomas Huth <[email protected]> :

Quoted 8 lines
Quoted 5 lines

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex.

That sounds somewhat wrong to me. QEMU now seems to support a transfer mode that is not really implemented.

On the other hand, the current implementation may not RFC compliant as the three modes (netascii, octet, mail) are not supported (but the RFC predates the usage of MAY/SHOULD/MUST, so it's unclear for me).

Quoted 8 lines

I have tried to add proper support, but this is more invasive as we cannot just seek in the file to get each block. However, this is something that I can do if compliance is important for QEMU.

Quoted 2 lines

I think you should at least issue a qemu_log_mask(LOG_UNIMP, "...") call in that case.

I can do that if needed.

That'd be better indeed. Otherwise people might wonder why things are not working. Warning that they have to do the LF -> CR,LF conversion by hand is important here.

Samuel

#6 lore raw

PATCH v2 1/1 tftp: fake support for netascii protocol

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +8 -3
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,
     return;
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "
+                    "no CR-LF conversion\n");
+      k += 9;
+  } else {
       tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
       return;
   }
 
-  k += 6; /* skipping octet */
-
   /* do sanity checks on the filename */
   if (!strncmp(req_fname, "../", 3) ||
       req_fname[strlen(req_fname) - 1] == '/' ||
Signature · 1 line
2.10.2
#7 lore raw
Your series seems to have some coding style problems. See output below for more information:

Hi,

Your series seems to have some coding style problems. See output below for more information:

Subject: [Qemu-devel] [v2] tftp: fake support for netascii protocol
Message-id: [email protected]
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
f8f1b3e tftp: fake support for netascii protocol

=== OUTPUT BEGIN ===
Checking PATCH 1/1: tftp: fake support for netascii protocol...
ERROR: suspect code indent for conditional statements (2, 6) #34: FILE: slirp/tftp.c:330:
+ if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+ k += 6;

ERROR: suspect code indent for conditional statements (2, 6) #36: FILE: slirp/tftp.c:332:
+ } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+ qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "

total: 2 errors, 0 warnings, 27 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#8 lore raw
In reply to Vincent Bernat
Your series seems to have some coding style problems. See output below for more information:

Hi,

Your series seems to have some coding style problems. See output below for more information:

Subject: [Qemu-devel] [v2] tftp: fake support for netascii protocol
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
f8f1b3e tftp: fake support for netascii protocol

=== OUTPUT BEGIN ===
Checking PATCH 1/1: tftp: fake support for netascii protocol...
ERROR: suspect code indent for conditional statements (2, 6) #34: FILE: slirp/tftp.c:330:
+ if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+ k += 6;

ERROR: suspect code indent for conditional statements (2, 6) #36: FILE: slirp/tftp.c:332:
+ } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+ qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "

total: 2 errors, 0 warnings, 27 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

Reviewed-by on v2 1/1
#9 lore raw
In reply to Vincent Bernat
Quoted 39 lines · Vincent Bernat

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +7 -1
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,
     return;
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "
+                    "no CR-LF conversion\n");
+      k += 9;

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, · line 343

Quoted 10 lines
slirp/tftp.c +1 -2
+  } else {
       tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
       return;
   }
 
-  k += 6; /* skipping octet */
-
   /* do sanity checks on the filename */
   if (!strncmp(req_fname, "../", 3) ||
       req_fname[strlen(req_fname) - 1] == '/' ||
#10 lore raw
In reply to Vincent Bernat
Quoted 29 lines · Vincent Bernat

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +1 -0
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,
     return;

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, · line 336

Quoted 10 lines
slirp/tftp.c +7 -1
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "
+                    "no CR-LF conversion\n");
+      k += 9;
+  } else {

This is an RFC violation. I don't think it's suitable for upstream QEMU.

The commit description says it would be "far more complex" to implement netascii. Is the LF -> CR LF and CR -> CR NUL transformation so hard?

CCing H. Peter Anvin who has TFTP expertise in case I'm missing something.

Stefan

#11 lore raw
Quoted 43 lines · Stefan Hajnoczi, on Mon 21 Nov 2016 14:46:16 +0000, wrote:
Quoted 29 lines · Vincent Bernat

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +1 -0
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,
     return;

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, · line 336

Quoted 10 lines
slirp/tftp.c +7 -1
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "
+                    "no CR-LF conversion\n");
+      k += 9;
+  } else {

This is an RFC violation. I don't think it's suitable for upstream QEMU.

Quoted 2 lines

The commit description says it would be "far more complex" to implement netascii. Is the LF -> CR LF and CR -> CR NUL transformation so hard?

I guess the question is that while the patch above could be accepted for the upcoming 2.8 (I don't see it breaking existing systems), a patch that would implement the transformation would be a lot more involved, and really not suitable for 2.8.

Samuel

#12 lore raw
Quoted 56 lines · Samuel Thibault
Quoted 6 lines · Stefan Hajnoczi, on Mon 21 Nov 2016 14:46:16 +0000, wrote:
Quoted 5 lines · Vincent Bernat

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the

netascii

Quoted 1 line
Quoted 1 line

protocol as well but do not perform the requested transformation

(LF ->

Quoted 1 line
Quoted 1 line

CR,LF) as it would be far more complex. The current implementation

is

Quoted 1 line
Quoted 1 line

good enough. A user has always the choice to preencode the served

file

Quoted 17 lines
Quoted 17 lines

correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +1 -0
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
Quoted 3 lines

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp,

Quoted 3 lines
slirp/tftp.c +0 -0
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp,

struct sockaddr_storage *srcsas,

Quoted 8 lines

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,

Quoted 8 lines
slirp/tftp.c +4 -1
     return;
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not

implemented, "

Quoted 5 lines

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, · line 336

Quoted 3 lines
slirp/tftp.c +3 -0
+                    "no CR-LF conversion\n");
+      k += 9;
+  } else {

This is an RFC violation. I don't think it's suitable for upstream

QEMU.

Quoted 2 lines

The commit description says it would be "far more complex" to

implement

Quoted 1 line

netascii. Is the LF -> CR LF and CR -> CR NUL transformation so

hard?

Quoted 7 lines

I guess the question is that while the patch above could be accepted for
the upcoming 2.8 (I don't see it breaking existing systems), a patch that would implement the transformation would be a lot more involved, and really not suitable for 2.8.

Samuel

A client that asks for netascii and falls back to octet if the requests fail could break.

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#13 lore raw
In reply to Samuel Thibault
Quoted 44 lines · Samuel Thibault
Quoted 43 lines · Stefan Hajnoczi, on Mon 21 Nov 2016 14:46:16 +0000, wrote:
Quoted 29 lines · Vincent Bernat

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +1 -0
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,
     return;

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, · line 336

Quoted 10 lines
slirp/tftp.c +7 -1
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, "
+                    "no CR-LF conversion\n");
+      k += 9;
+  } else {

This is an RFC violation. I don't think it's suitable for upstream QEMU.

Quoted 7 lines
Quoted 2 lines

The commit description says it would be "far more complex" to implement netascii. Is the LF -> CR LF and CR -> CR NUL transformation so hard?

I guess the question is that while the patch above could be accepted for the upcoming 2.8 (I don't see it breaking existing systems), a patch that would implement the transformation would be a lot more involved, and really not suitable for 2.8.

This pull request cannot be accepted for QEMU 2.8 because it is not a bug fix. QEMU is in hard feature freeze (until mid-December):
http://qemu-project.org/Planning/HardFeatureFreeze
http://qemu-project.org/Planning/2.8

If you decide to implement netascii in the future, please update the documentation in qemu-options.hx:

The TFTP client on the guest must be configured in binary mode (use the command @code{bin} of the Unix TFTP client).

Thanks,
Stefan

#14 lore raw

❦ 22 novembre 2016 10:49 GMT, Stefan Hajnoczi <[email protected]> :

Quoted 9 lines
Quoted 4 lines

I guess the question is that while the patch above could be accepted for the upcoming 2.8 (I don't see it breaking existing systems), a patch that would implement the transformation would be a lot more involved, and really not suitable for 2.8.

This pull request cannot be accepted for QEMU 2.8 because it is not a bug fix. QEMU is in hard feature freeze (until mid-December):
http://qemu-project.org/Planning/HardFeatureFreeze
http://qemu-project.org/Planning/2.8

So, I'll implement netascii in the coming weeks and update the proposed patch.

Signature · 2 lines
Don't use conditional branches as a substitute for a logical expression.
            - The Elements of Programming Style (Kernighan & Plauger)
#15 lore raw
Quoted 7 lines · Vincent Bernat

❦ 22 novembre 2016 10:49 GMT, Stefan Hajnoczi <[email protected]> :

Quoted 5 lines
Quoted 4 lines

I guess the question is that while the patch above could be accepted for the upcoming 2.8 (I don't see it breaking existing systems), a patch that would implement the transformation would be a lot more involved, and really not suitable for 2.8.

Quoted 7 lines
Quoted 4 lines

This pull request cannot be accepted for QEMU 2.8 because it is not a bug fix. QEMU is in hard feature freeze (until mid-December):
http://qemu-project.org/Planning/HardFeatureFreeze
http://qemu-project.org/Planning/2.8

So, I'll implement netascii in the coming weeks and update the proposed patch.

Excellent, thank you!

Stefan

#16 lore raw
In reply to Stefan Hajnoczi
Quoted 48 lines · Stefan Hajnoczi
Quoted 6 lines · Vincent Bernat

From: Vincent Bernat <[email protected]>

Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF

->

Quoted 2 lines

CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served

file

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp,

Quoted 20 lines

correctly.

---
 slirp/tftp.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
slirp/tftp.c +1 -0
index c1859066ccb2..6907d5b92074 100644
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/log.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -326,13 +327,17 @@ static void tftp_handle_rrq(Slirp *slirp,

struct sockaddr_storage *srcsas,

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas,

Quoted 8 lines
slirp/tftp.c +4 -1
     return;
   }
 
-  if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) {
+  if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) {
+      k += 6;
+  } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) {
+      qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not

implemented, "

slirp/tftp.c static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, · line 336

Quoted 3 lines
slirp/tftp.c +3 -0
+                    "no CR-LF conversion\n");
+      k += 9;
+  } else {

This is an RFC violation. I don't think it's suitable for upstream QEMU.

Quoted 7 lines

The commit description says it would be "far more complex" to implement netascii. Is the LF -> CR LF and CR -> CR NUL transformation so hard?

CCing H. Peter Anvin who has TFTP expertise in case I'm missing something.

Stefan

It should be trivial to do. The one caveat is that the tsize extension needs to be disabled for a netascii read.

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#17 lore raw
In reply to Stefan Hajnoczi

❦ 21 novembre 2016 14:46 GMT, Stefan Hajnoczi <[email protected]> :

Quoted 2 lines

The commit description says it would be "far more complex" to implement netascii. Is the LF -> CR LF and CR -> CR NUL transformation so hard?

Currently, the code uses lseek to send each block. It is just a matter of doing nr_block*512. If there is a transformation, this cannot work this way. But this can be done, we'll just have to maintain an offset.

Not knowing the final size is not a problem, just send back 0 as the size.

Signature · 2 lines
Vincent Bernat — [email protected]
❬❱ https://www.exoscale.ch
#18 lore raw
Quoted 5 lines · Vincent Bernat

❦ 21 novembre 2016 14:46 GMT, Stefan Hajnoczi <[email protected]> :

Quoted 1 line

The commit description says it would be "far more complex" to

implement

Quoted 1 line

netascii. Is the LF -> CR LF and CR -> CR NUL transformation so

Quoted 8 lines

hard?

Currently, the code uses lseek to send each block. It is just a matter of doing nr_block*512. If there is a transformation, this cannot work this way. But this can be done, we'll just have to maintain an offset.

Not knowing the final size is not a problem, just send back 0 as the size.

Incidentally, it would definitely be a good thing to enable the blksize extension.

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#19 lore raw
In reply to Samuel Thibault

❦ 19 novembre 2016 23:30 +0100, Samuel Thibault <[email protected]> :

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I think you should at least issue a qemu_log_mask(LOG_UNIMP, "...") call in that case.

I can do that if needed.

That'd be better indeed. Otherwise people might wonder why things are not working. Warning that they have to do the LF -> CR,LF conversion by hand is important here.

I have sent an updated patch for that.

Totally unrelated, but on Debian, I have to use -r instead of -Wl,r for LD_REL. This is explained here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837574

I don't think the patch has been forwarded to you yet.

Signature · 2 lines
Don't patch bad code - rewrite it.
            - The Elements of Programming Style (Kernighan & Plauger)