The Mishna 61a says that chazal were matir to give shalom to goyim because of darkei shalom. Rashi explains that the reason it should be prohibited m'ikar hadin (if not for darkei shalom) is because shalom is a name of Hashem and there is only a heter to use it in giving shalom to another jew. However, the gemara 62a asks: "if one is allowed to give words of encouragement to a goy who is working, he should surely be allowed to give shalom". The gemara proceeds to say that the argument for prohibiting it is specifically during their holiday where it is likely to cause them to thank their idols for the Jew showing them respect. Based on Rashi in the mishna there is a very significant chiddush in being able to give them shalom, in that one is entitled to use the name of Hashem. If so, what is the question of the gemara? The Rashash is bothered by this question and says that even when one gave words of encouragement to continue working, the name of Hashem was invoked. Therefore, the gemara asks that since the name of Hashem was invoked for that purpose, it can certainly be used to give Shalom.
The gemara says that Rav Kahana gave shalom to a goy by saying "Shalom to Mar". Rashi explains that he didn't intend to refer to the goy, but rather to his Rebbi. Tosafos doesn't understand what would compel rashi to say such a thing since we only find a prohibition in repeating shalom, but for saying it only once we don't need a heter of darkei shalom [Tosafos also asks that it seems to be a geneivas da'as of the goy]. Tosafos seems to imply that there is some inherent prohibition to repeat shalom, and is not clear why. Rashi however explains that the problem with repeating Shalom is predicated on the problem with saying it in the first place, in that it is using the name of Hashem. Therefore rashi explains that although the heter of darkei shalom would permit saying it once, it would not permit repeating it. We can now understand why Rashi l'shitaso is compelled to say that R' Kahana would have intent for his rebbi when giving shalom, because rashi is trying to explain how R' Kahana avoided the prohibition of using Hashem's name for a goy [and apparently didn't want to invoke the leniency of darkei shalom, whereas R' Chisda who would give them Shalom was willing to rely on the darkei shalom heter (the Ran adds that the chiddush of R' chisda is that he jumped at the opportunity to say shalom first based on the darkei shalom heter, because if he waited for them to say shalom first the expectation would be to repeat it twice so he tried to think ahead to avoid that)]. Perhaps rashi would hold that the issue of geneivas da'as would also not apply since he truly did intend to greet the goy, but the for the use of the name of Hashem he had to intend to give the bracha of Shalom to his rebbi.